Aleksandar Stefanović
Aleksandar Stefanović

Reputation: 1593

Can't use Selenium dependency in Android (works in plain Java)

I've previously used selenium-java dependency (via Maven) in plain Java, and it worked. However, when I try to add that same dependency to my Android project:

dependencies {

    ...

    compile 'com.android.support:recyclerview-v7:25.1.0'
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    compile 'org.seleniumhq.selenium:selenium-java:3.0.1'

}
repositories {
    mavenCentral()
}

I get this error:

Error:Failed to notify project evaluation listener.

I've tried to change the compile keyword to all possible variants, and also tried putting the dependency in the main Gradle file (above code is from the Gradle file of the module, but all other dependencies go there anyway, so it shouldn't matter).

I've also tried manually adding .jar files, but some of the classes (e.g. HtmlUnitDriver class) are missing, so I'm guessing that's not correct way to do it either.

I'm using Android Studio, with the latest SDKs and the recent Gradle version (2.2.3).

P.S. What I need Selenium for is for interacting with a website. I want to put text in input fields, and then press "login" button (all via code), so that I can interact with a website and fetch its data, and display it etc. .If there is a better solution to my need, please share it.

Upvotes: 1

Views: 309

Answers (1)

Leonardo Sibela
Leonardo Sibela

Reputation: 2189

Selenium is not meant for android: https://testobject.com/blog/2016/07/can-selenium-be-used-for-mobile-testing.html

You should use selendroid: http://selendroid.io/

or appium: http://appium.io/

Upvotes: 1

Related Questions