如果appium服务器和移动设备仅通过USB连接,是否可以运行测试脚本?

时间:2016-01-19 07:55:57

标签: java android automation appium

目前我正在运行我的测试脚本,其中appium服务器和移动设备在同一个WiFi网络上。

但是当appium服务器和移动设备在不同的WiFi网络上/未连接到WiFi但只通过USB连接时,我在尝试使用脚本时会出现以下错误。

Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a newsession. Possible causes are invalid address of the remote server or browser start-up failure.

Build info: version: 'unknown', revision: 'unknown', time: 'unknown'

System info: host: 'admin-PC', ip:'127.0.0.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1',
java.version: '1.8.0_45'

Driver info: driver.version:AndroidDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:593)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:109)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:39)
at MFKPackage1.MFKSmartPhone1.initializeApp(MFKSmartPhone1.java:76)
at MFKPackage1.MFKSmartPhone1.main(MFKSmartPhone1.java:302)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:136)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:152)
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:270)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:260)
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:161)
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:153)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:271)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:254)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:126)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:72)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:133)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:572)
...
8 more

appium服务器和移动设备是否必须位于同一个WiFi网络上?我们不能通过USB运行我们的测试脚本吗?

1 个答案:

答案 0 :(得分:-1)

是的,你可以100%使用appium而不是USB。我目前正在测试USB。

通过我的一些测试,USB测试似乎更可靠。

发布您的代码,我会看看我是否能看到问题。

希望这有帮助, 利安