我正在尝试开始使用适用于android虚拟设备的selendroid和selenium,但我遇到了一些问题。我已经安装了所有的java/android sdk/eclipse软件,我可以很好地运行selenium chromedriver测试。但是,当我尝试运行一个测试来启动android虚拟设备时,它永远不会启动,应用程序也不会在http://localhost:4444/wd/hub/status页面中列出。
下面是我的通用测试。如果我运行下面的代码,服务器将启动,我可以从状态页面看到我的本地主机数据,但我的应用程序版本没有列出。如果我运行java -jar selendroid-standalone-0.11.0-with-dependencies.jar -app selendroid-test-app-0.11.0.apk,那么我可以看到我的应用程序列在状态页面中。我试过在虚拟设备上预装应用程序,也尝试在虚拟设备上使用已签名的应用程序,但两者都不起作用。
我几乎走到了死胡同,就像在哪里寻找解决方案一样。我已经花了3-4天寻找解决方案,但似乎找不到它。目前在java项目中,我只加载了selenium和selendroid .jar文件依赖项。我还没有安装任何jUnit或任何‘测试’相关的东西
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();
}
}发布于 2014-10-21 11:18:15
也许你想确定“DeviceTargetPlatform.ANDROID17”是不是真的把你的设备当做ANDROID17。那就是当你运行你的测试时,检查日志。如果http://localhost:4444/wd/hub/status对你有效,请在那里检查你的设备目标。
我之前也遇到过同样的问题,我只是发现我使用的是'ANDROID18‘,而不是ANDROID17。
https://stackoverflow.com/questions/26468630
复制相似问题