How do I add Selendroid to android studio for web scraping?
Asked Answered
M

2

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...

Mclyman answered 13/8, 2015 at 1:27 Comment(1)
For future reference, this is a good website for tentatively finding Gradle dependencies: gradleplease.appspot.com/#SeleniumRivy
P
-1

Something like this:

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

         } 
 }

(adding maven repo using gradle)

Periphrasis answered 19/8, 2015 at 22:13 Comment(2)
@Steve what it says? For me it firstly showed an error but after "sync again" it workedPeriphrasis
it does not import the Selenium library. For example, I try to use a WebDriver/WebElement and it does not workMclyman
L
-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.

Ligule answered 22/8, 2015 at 11:2 Comment(2)
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 1Mclyman
Then try: Build >> Clean Project OR File >> Invalidate Caches / Restart OR maybe you have THIS problem, read the accepted answerLigule

© 2022 - 2024 — McMap. All rights reserved.