Appium:尝试启动Android服务器时出现连接错误

时间:2016-04-18 07:11:11

标签: java selenium appium

代码: public static void main(String [] args)抛出MalformedURLException {

    File appDirectory = new File("src");
    File app = new File(appDirectory, "Cricbuzz.apk");

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,MobilePlatform.ANDROID);
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Android Emulator");

    capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "100");
    capabilities.setCapability("app", app.getAbsolutePath());
    System.out.println("Reached before driver");

    WebDriver driver = new AndroidDriver(new URL(
            "http://127.0.0.1:4723/wd/hub"), capabilities);
}

}

注意:我已经启动了appium服务器和虚拟设备。我不确定MobileCapabilityType.DEVICE_NAME," Android Emulator"是指一般的虚拟设备,还是应该是设备的确切名称。 我运行adb -devices,得到了模拟器的确切名称并粘贴它,仍然得到相同的错误。感谢您帮助理解错误。

错误抛出 -

线程中的异常" main" org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器的无效地址或浏览器启动失败。 构建信息:版本:' 2.47.1',修订版:' 411b314',时间:' 2015-07-30 02:56:46' 系统信息:主机:' RAJIT-PC',ip:' 10.0.0.65',os.name:' Windows 8.1',os.arch:& #39; amd64',os.version:' 6.3',java.version:' 1.8.0_77' 驱动程序信息:driver.version:AndroidDriver     在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:589)     at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)     at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)     在io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)     在org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)     在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:128)     在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:141)     在io.appium.java_client.DefaultGenericMobileDriver。(DefaultGenericMobileDriver.java:37)     在io.appium.java_client.AppiumDriver。(AppiumDriver.java:160)     在io.appium.java_client.AppiumDriver。(AppiumDriver.java:168)     在io.appium.java_client.android.AndroidDriver。(AndroidDriver.java:69)     在AppTest.main(AppTest.java:31) 引起:org.openqa.selenium.WebDriverException:org.apache.http.conn.HttpHostConnectException:连接到127.0.0.1:4723 [/127.0.0.1]失败:连接被拒绝:连接 构建信息:版本:' 2.47.1',修订版:' 411b314',时间:' 2015-07-30 02:56:46' 系统信息:主机:' RAJIT-PC',ip:' 10.0.0.65',os.name:' Windows 8.1',os.arch:& #39; amd64',os.version:' 6.3',java.version:' 1.8.0_77' 驱动程序信息:driver.version:AndroidDriver     在io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:64)     在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:568)     ......还有11个 引起:org.apache.http.conn.HttpHostConnectException:连接到127.0.0.1:4723 [/127.0.0.1]失败:连接被拒绝:连接     at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)     at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)     at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)     在org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)     在org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)     在org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)     在org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)     在org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)     在org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)     在org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)     在org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:143)     在org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:89)     在org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:134)     在io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:52)     ......还有12个 引起:java.net.ConnectException:连接被拒绝:连接     at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)     在java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)     在java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)     在java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)     在java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)     在java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)     在java.net.Socket.connect(Socket.java:589)     at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:74)     at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)     ......还有25个

0 个答案:

没有答案