【发布时间】:2017-03-11 08:09:31
【问题描述】:
首先,出于某种原因,这种情况目前仅发生在 Android 平板电脑上。 我在运行 Android 6.0 到 4.4 的手机上尝试过,它可以正常工作。
但出于某种原因,在平板电脑上却没有。
我正在尝试在屏幕上找到一个广告,我正在搜索它:
private boolean findAdContainerDefault (){
boolean found = false;
try {
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//android.widget.ViewSwitcher/android.widget.FrameLayout/android.webkit.WebView")));
found = true;
} catch (Exception e) {}
return found;
}
或者这个:
private boolean findAdContainerFor44 (){
boolean found = false;
try {
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//android.widget.ViewSwitcher/android.widget.FrameLayout/android.view.View")));
found = true;
} catch (Exception e) {}
return found;
}
因为有时 webview 不会在某些设备的检查器中显示。
这项工作在手机上就像一个魅力,但由于某种原因在平板电脑上它有时工作有时不工作,如果我在测试中使用这种方法 8 次,它可能工作 6 次 & 在第 7 次崩溃一切,即使我有试着抓住它。
显然这是一个服务器端错误: 这是我得到的错误:
org.openqa.selenium.support.ui.ExpectedConditions findElement
WARNING: WebDriverException thrown by findElement(By.xpath: //android.widget.ViewSwitcher/android.widget.FrameLayout/android.webkit.WebView)
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 101 milliseconds
这就是我在服务器端得到的:
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.ViewSwitcher/android.widget.FrameLayout/android.webkit.WebView","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.ViewSwitcher/android.widget.FrameLayout/android.webkit.WebView","context":"","multiple":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.ViewSwitcher/android.widget.FrameLayout/android.webkit.WebView using XPATH with the contextId: multiple: false
> info: [debug] [BOOTSTRAP] [debug] Command returned error:java.lang.RuntimeException: Failed to Dump Window Hierarchy
> info: [debug] Condition unmet after 64ms. Timing out.
> info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"Failed to Dump Window Hierarchy"},"sessionId":"0552388e-e8d3-4be6-ba40-1e8225064654"}
> info: <-- POST /wd/hub/session/0552388e-e8d3-4be6-ba40-1e8225064654/element 500 66.384 ms - 200
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":13,"value":"Failed to Dump Window Hierarchy"}
是已知的错误还是什么? 有解决办法吗?
【问题讨论】: