如何研究selendroid服务器错误?

时间:2015-03-04 06:30:18

标签: java android-emulator selendroid

我已尝试使用以下编码在Android模拟器中运行我的测试用例。它抛出下面描绘的错误信息。

private WebDriver driver;`
private String baseUrl;

@BeforeSuite
public void setUp() throws Exception {
    SelendroidConfiguration config = new SelendroidConfiguration();
    config.addSupportedApp("selendroid-test-app-0.14.0.apk");
    SelendroidLauncher selendroidServer = new SelendroidLauncher(config);
    selendroidServer.launchSelendroid();
    SelendroidCapabilities caps = new SelendroidCapabilities("io.selendroid.testapp:0.14.0");
    driver = new SelendroidDriver(caps);
    baseUrl = "https://www.google.co.in/";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testUntitled() throws Exception {
   System.out.println("Start Execution.........");
   driver.get(baseUrl + "/");
   driver.findElement(By.id("gbqfq")).sendKeys("Test");
   driver.findElement(By.id("gbqfb")).click();
}
@AfterSuite
public void tearDown() throws Exception {
    driver.quit();
}

堆栈跟踪

setUp(mobileweb.photocentric.SampleTest)  Time elapsed: 0 sec  <<< FAILURE!
org.openqa.selenium.SessionNotCreatedException: The requested application under test is not configured in selendroid server.
Command duration or timeout: 207 milliseconds

Driver info: io.selendroid.SelendroidDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
    at io.selendroid.SelendroidDriver.<init>(SelendroidDriver.java:61)
    at mobileweb.photocentric.ScrollArticleTest.setUp(ScrollArticleTest.java:25)
Caused by: org.openqa.selenium.SessionNotCreatedException: The requested application under test is not configured in selendroid server.

2 个答案:

答案 0 :(得分:1)

诀窍是,您不必指定正在测试的应用程序。

控制 - &gt; Guide

尝试:

SelendroidConfiguration config = new SelendroidConfiguration();
selendroidServer = new SelendroidLauncher(config);
selendroidServer.launchSelendroid();
DesiredCapabilities caps = SelendroidCapabilities.android();
driver = new SelendroidDriver(caps);

答案 1 :(得分:0)

SelendroidCapabilities selendroidCapabilities = new SelendroidCapabilities();

        // Create selendroid driver instance
        selendroidDriver = new SelendroidDriver(new URL("http://localhost:4444/wd/hub/"),selendroidCapabilities);

如果它仍然提供UnreachableBrowserException,请在cmd中键入ipconfig并用IPv4地址替换localhost并尝试运行。