javaandroid-studioselendroid

Selendroid in Android Studio


I'm using Android studio to build a projects My Question is there any way to setup Selendroid in Android studio? Please Teach me step by step.

I already added this to my Gradle

In my Gradle Project:

 dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:23.1.0'
        compile 'org.seleniumhq.selenium:selenium-java:2.48.2'
    }buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
}

In my Module app:

dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'
    classpath 'org.seleniumhq.selenium:selenium-java:2.47.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

My Main Activity

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    SelendroidCapabilities capa = new SelendroidCapabilities("io.selendroid.testapp:0.17.0");

    WebDriver driver = new WebDriver(capa);
    WebElement inputField = driver.findElement(By.id("my_text_field"));
    Assert.assertEquals("true", inputField.getAttribute("enabled"));
    inputField.sendKeys("Selendroid");
    Assert.assertEquals("Selendroid", inputField.getText());
    driver.quit();
}

My Error is SelendroidCapabilities capa = new SelendroidCapabilities("io.selendroid.testapp:0.17.0"); Error:(5, 1) error: package io.selendroid.client does not exist


Solution

  • You should write anything in MainActivity instead create a new Java Class ins scr-> Main -> add your Test case code there.

    then go to build variant -> select Unit Tests and run the Test case