others - selenium - 检测WebDriverException:An unknown server-side error(未知服务器端错误)

有时Selenium /Appium远程服务器会失败:(收到WebDriverException,具体来说,我从SauceLabs收到这个:


org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not proxy. Proxy error: Could not proxy command to remote server. Original error: Error: ESOCKETTIMEDOUT (WARNING: The server did not provide any stacktrace information)


Command duration or timeout: 0 milliseconds


Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'


System info: host: '87ffea49770c', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.14.94-73.73.amzn1.x86_64', java.version: '1.8.0_232'


Driver info: io.appium.java_client.android.AndroidDriver


Capabilities {...}


Session ID: db1bcb92c9e245c1b83129b58cd726a3


*** Element info: {Using=xpath, value=(//*[contains(@cl...



我使用TestNG,并考虑编写一个ITestListener来简单地通过请求一个新会话来处理这些,但是,我不确定WebDriverException是否是唯一的服务器端故障。

post script,这是完整的堆栈跟踪:


Session ID: db1bcb92c9e245c1b83129b58cd726a3


*** Element info: {Using=xpath, value=(//*[contains(@class,'public-chat')]/descendant::chat-message)[last()]}


 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)


 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)


 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)


 at java.lang.reflect.Constructor.newInstance(Constructor.java:423)


 at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)


 at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)


 at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)


 at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)


 at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)


 at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)


 at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)


 at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)


 at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)


 at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)


 at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)


 at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)


 at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:61)


 at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)


 at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)


 at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428)


 at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:151)


 at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1)


 at io.appium.java_client.android.AndroidDriver.findElementByXPath(AndroidDriver.java:1)


 at org.openqa.selenium.By$ByXPath.findElement(By.java:353)


 at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)


 at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:57)


 at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)


 at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)



时间: 原作者:

xpath是appium最糟糕的策略,我不会使用这个xpath,Element info: {Using=xpath, value=(//*[contains(@class,'public-chat')]/descendant::chat-message)[last()]}尝试为应用程序获取更短的xpath或id,并在元素之前添加一个web driver wait。

原作者:
...