【发布时间】:2018-11-15 14:10:54
【问题描述】:
大家好,我得到了一个异常名称 webdriverException:在我的 IOS 脚本运行期间某些元素上的连接重置,我使用的是 appium v1.8.0。它不是每次都发生,而是在很多元素上都有一段时间,当我捕捉到这个异常并尝试使用相同的操作时,它会起作用。
下面给出的所有功能:
`cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
cap.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.4");
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 7 Plus");
cap.setCapability(MobileCapabilityType.BROWSER_NAME, "");
cap.setCapability(MobileCapabilityType.SUPPORTS_ALERTS,true);
cap.setCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES,true);
cap.setCapability(MobileCapabilityType.SUPPORTS_FINDING_BY_CSS,true);
cap.setCapability ( "useNewWDA", true);
cap.setCapability ("webviewConnectRetries", "25" );
cap.setCapability( "usePrebuiltWDA", true );
cap.setCapability("simpleIsVisibleCheck",false);
cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT,"120");`
下面给出的例外情况:
org.openqa.selenium.WebDriverException: java.net.SocketException: Connection reset
Build info: version: '3.3.1', revision: '5234b325d5', time: '2017-03-10 09:10:29 +0000'
System info: host: 'xxxxxxxx.local', ip: 'fe80:0:0:0:1cf3:2859:a854:82a0%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_171'
Driver info: driver.version: IOSDriver
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:177)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteTimeouts.implicitlyWait(RemoteWebDriver.java:835)
at io.appium.java_client.pagefactory.AppiumElementLocator.changeImplicitlyWaitTimeOut(AppiumElementLocator.java:81)
at io.appium.java_client.pagefactory.AppiumElementLocator.waitFor(AppiumElementLocator.java:87)
at io.appium.java_client.pagefactory.AppiumElementLocator.findElements(AppiumElementLocator.java:133)
at io.appium.java_client.pagefactory.interceptors.InterceptorOfAListOfElements.intercept(InterceptorOfAListOfElements.java:50)
at $java.util.ArrayList$$EnhancerByCGLIB$$b5855c01.get(<generated>)
at Main.Regression.HomeIconSelection(Regression.java:899)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
at org.testng.SuiteRunner.run(SuiteRunner.java:254)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:155)
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:284)
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:261)
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165)
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:142)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:88)
at io.appium.java_client.remote.AppiumCommandExecutor.doExecute(AppiumCommandExecutor.java:132)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:162)
... 34 more
谁能帮我解决这个问题?
【问题讨论】:
-
您使用的是什么 appium-java-client 版本?最好在您遇到此错误的地方添加驱动程序初始化和确切代码
-
我使用的是 5.0.0 BETA6
-
driver = new IOSDriver
(new URL("0.0.0.0:4723/wd/hub"), cap); -
重要的是,我正在使用带有 testNG 的页面工厂框架。它是随机发生的,假设我尝试单击标签栏元素并且有时它会经历一段时间的连接重置,我使用了 try catch 和相同的元素在 catch 语句中工作,例如尝试 { objTabBarElement.MyAccountBar.click(); } } catch (WebDriverException e) { objTabBarElement.MyAccountBar.click(); }
-
将客户端库更新到 6.0.0,这可能会有所帮助。不要显式设置 selenium 库,Appium 已经是一个了
标签: java selenium-webdriver appium appium-ios appium-android