15

Please see edits below before answering!

I am trying to set up dynamic web scraping with Selenium, however, I can't seem to find the necessary gradle dependencies/lib files to add to my project. I looked at Selendroid/Selenium's website and was unable to find the necessary configuration information. I am assuming that I need the webdriver as I am going to be scraping web data. As a side note, I have decided on using Selendroid after finding HtmlUnit incompatible with Android, and after finding no viable alternatives. All help is appreciated.

(Other questions addressing this problem remain unanswered)

Edit: so using Exeon's suggestion, I found the following dependency for Selendroid:

compile 'io.selendroid:selendroid-client:0.16.0'
However, upon running my application, I get the following error (repeated around 10 times):

Warning:Dependency org.apache.httpcomponents:httpclient:4.3.6 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages

Note, I did try using the following as well:

compile 'org.testcontainers:selenium:0.9.7'

but I was met with the same error...

mlz7
  • 2,067
  • 3
  • 27
  • 51
  • 1
    For future reference, this is a good website for tentatively finding Gradle dependencies: http://gradleplease.appspot.com/#Selenium – Sherlock Aug 19 '15 at 22:22

2 Answers2

-1

Something like this:

 buildscript {
     repositories {
         mavenCentral()
     }
     dependencies {
         classpath 'org.seleniumhq.selenium:selenium-java:2.47.1'

         } 
 }

(adding maven repo using gradle)

kandi
  • 1,098
  • 2
  • 12
  • 24
  • @Steve what it says? For me it firstly showed an error but after "sync again" it worked – kandi Aug 20 '15 at 10:40
  • it does not import the Selenium library. For example, I try to use a WebDriver/WebElement and it does not work – mlz7 Aug 20 '15 at 11:36
-1

For your error regarding the dependency issue you could try to exclude the httpclient from the selendroid library. I tried it too but I got other dependency issues, but you could give it a try :

compile('io.selendroid:selendroid-client:0.16.0') {
        exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
    }

After that I was able to import like that:

import io.selendroid.client.*;

and use the WebDriver.

weletonne
  • 489
  • 5
  • 10
  • this ves me the the error: Error:Execution failed for task ':app:preDexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1 – mlz7 Aug 22 '15 at 15:12
  • Then try: `Build >> Clean Project` **OR** File >> `Invalidate Caches / Restart` **OR** maybe you have [THIS](http://stackoverflow.com/questions/23847482/error-gradle-execution-failed-for-task-apppredexdebug) problem, read the accepted answer – weletonne Aug 22 '15 at 15:20