0

I am trying to get started with selendroid and selenium for android virtual devices but im having a few issues. I have all the java/android sdk/eclipse software installed and i can run selenium chromedriver tests fine. BUT when i try to run a test that starts the android virtual device, it never starts and the app doesnt list in the http://localhost:4444/wd/hub/status page.

My generic test is below. If i run this code below, the server will start and i can see my local host data from the status page BUT my app version doesnt get listed. If i run java -jar selendroid-standalone-0.11.0-with-dependencies.jar -app selendroid-test-app-0.11.0.apk then i can see my app listed in the status page. I have tried with the app pre-loaded on the virtual device and also wit the signed app on the virtual device, neither have worked.

I am pretty much at a dead end as where else to look for the solution. I have spent 3-4 days looking for a solution but cant seem to find it. Currently in the java project i have only the selenium and selendroid .jar file dependencies loaded. I have yet to install any jUnit or anything 'test' releated

package testpackage;

import io.selendroid.SelendroidCapabilities;
import io.selendroid.device.DeviceTargetPlatform;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class testClass {

    /**
     * @param args
     */

    public static void runSelendroidTest() throws Exception {

        // specify test capabilities (your 'test environment')
        SelendroidCapabilities capa = new SelendroidCapabilities("io.selendroid.testapp:0.11.0");

        // explicitly state that we want to run our test on an Android API level 17 device
        capa.setPlatformVersion(DeviceTargetPlatform.ANDROID17);

        // explicitly state that we use an emulator (an AVD) for test execution rather than a physical device
        capa.setEmulator(true);

        // start a new WebDriver
        WebDriver driver = new SelendroidDriver(capa);

        // execute a very simple test
        WebElement inputField = driver.findElement(By.id("my_text_field"));
        Assert.assertEquals("true", inputField.getAttribute("enabled"));
        inputField.sendKeys("Selendroid");
        Assert.assertEquals("Selendroid", inputField.getText());

        // quit testing
        driver.quit();

    }

}
user616
  • 783
  • 4
  • 18
  • 44

1 Answers1

0

maybe you wanna make sure if the 'DeviceTargetPlatform.ANDROID17' really targets your device as ANDROID17. That is when you run your test, check the log. If the http://localhost:4444/wd/hub/status works for you, kindly check your device target there.

I had the same issue before and i just figured out that I was using the 'ANDROID18' not ANDROID17.

jemuzu
  • 1
  • 1
  • Yes, my status page states ANDROID17 `{"value":{"os":{"name":"Windows 7","arch":"amd64","version":"6.1"},"build":{"browserName":"selendroid","version":"0.11.0"},"supportedDevices":[{"emulator":true,"screenSize":"WSVGA","avdName":"Test","platformVersion":"17"}],"supportedApps":[{"mainActivity":"io.selendroid.androiddriver.WebViewActivity","appId":"io.selendroid.androiddriver:0.11.0","basePackage":"io.selendroid.androiddriver"}]},"status":0}` – user616 Oct 21 '14 at 14:09
  • are you running your test with 'already running' emulator or not? – jemuzu Oct 22 '14 at 03:37
  • I have tried it both ways, emulator running and emulator not running. Both ways i get the same result – user616 Oct 22 '14 at 14:02