简体   繁体   English

Appium 1.4.16处理命令时发生未知的服务器端错误

[英]Appium 1.4.16 An unknown server-side error occurred while processing the command

First of all this happens for the moment only on Android tablets for some reason. 首先,由于某种原因,目前仅在Android平板电脑上会发生这种情况。 I tried it on phones with Android 6.0 to 4.4 and it's working. 我在Android 6.0至4.4的手机上尝试过,并且可以正常工作。

But for some reason on tablets it doesn't. 但是出于某种原因,在平板电脑上却没有。

I'm trying to find an advertisement on the screen for this I'm searching it with either this : 我正在尝试在屏幕上为此找到广告,我正在使用以下方法进行搜索:

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;
}

or this : 或这个 :

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;
}

since sometimes webview doesn't show in the inspector for some devices. 因为有时某些设备的检查器中不会显示webview。

This work like a charm on phones but for some reason on tablets it's sometimes working sometimes not and if i'm using this methods 8 times in my test it might work 6 times & on the 7th crash everything even if I have a try catch over it. 这项功能在手机上就像魅力一样,但由于某些原因在平板电脑上有时无法正常工作,如果我在测试中使用8次此方法,它可能会工作6次,并且在第7次崩溃时,即使我尝试了一下,它。

And apparently it's a server side error : this is the error i get : 显然这是服务器端错误:这是我得到的错误:

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

and this is what i get in the server side : 这就是我在服务器端得到的:

> 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"}

Is it known bug or something ? 是已知的bug还是什么? Is there a work around ? 有没有解决的办法?

Instead of using visibilityOfElementLocated you can use PresenceOfElement 可以使用PresenceOfElement代替使用visibleivityOfElementLocated

wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//android.widget.ViewSwitcher/android.widget.FrameLayout/android.view.View"))); 

I would prefer to use relative XPath with some criteria such as adding some attribute value (name, content-desc, text). 我宁愿将相对XPath与某些条件结合使用,例如添加一些属性值(名称,content-desc,文本)。 In the below example, I am using attribute text as "MyWebView". 在下面的示例中,我将属性文本用作“ MyWebView”。 Replace this value with your attribute. 将此值替换为您的属性。

wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//android.view.View[@text='MyWebView']"))); 

You can also use the below method to find if element is present on screen or not. 您也可以使用以下方法查找屏幕上是否存在元素。

protected boolean isElementPresent(By by) throws IOException {
    boolean isElement = false;
    try
    {
        if (driver.findElement(by) != null)
        {
            isElement = true;
            return isElement;
        }
    }
    catch(Exception e)
    {
        System.out.println("Element not found");
        isElement = false;
        return isElement;
    }
    return isElement;
}

I have define this in AbstractClass and use if quite often throughout the test framework. 我已经在AbstractClass中定义了这一点,并在整个测试框架中经常使用。

To use in other test class - 要在其他测试课程中使用-

public class testAdBanner extends AbstractMethods {

    public AppiumDriver<?> driver;

    public testAdBanner(AppiumDriver<?> driver2) {
        super(driver2);
        this.driver = driver2;
    }

    public boolean isAdBanner() throws IOException {
        return isElementPresent(By.xpath("//android.view.View[@text='MyWebView']"));
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Appium向下滚动时,“处理命令时出现未知的服务器端错误” - “An unknown server-side error occurred while processing the command” while doing scroll down using Appium Appium 未知错误:处理命令时发生未知的服务器端错误。 原始错误:重新安装需要“app”选项 - Appium unknow error: An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall Appium 桌面 Java 。 所需的能力。 Android 设备:处理命令时发生未知的服务器端错误 - Appium Desktop Java . Desired Capabilities. Android Device : An unknown server-side error occurred while processing the command 处理命令时发生未知的服务器端错误。 原始错误:未知错误:无法使用模拟器浏览器聚焦元素 - An unknown server-side error occurred while processing the command. Original error: unknown error: cannot focus element using emulator browser 在 Android 上运行 Appium 测试时出错“发生未知的服务器端错误..” - Getting error while running Appium test on Android " An unknown server-side error occurred.." InternalServerError:处理此请求时发生未知服务器错误 - InternalServerError: Unknown server error occurred when processing this request 服务器端Java错误 - Server-side Java error 尝试启动真正的 android 手机的 android 应用程序时出现“未知的服务器端错误” - "An unknown server-side error" when tried to launch android app of real android phone 将处理草图保存到服务器端的PNG文件,没有GUI /显示 - Save a Processing sketch to a PNG file, server-side with no GUI/display 处理脏区时发生内部错误 - An internal error occurred while processing dirty regions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM