获取io.appium.uiautomator2.common.exceptions.UiAutomator2Exception错误 [英] Getting io.appium.uiautomator2.common.exceptions.UiAutomator2Exception error

查看:38
本文介绍了获取io.appium.uiautomator2.common.exceptions.UiAutomator2Exception错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Android电视流媒体应用程序编写自动化程序,运行测试时遇到问题。当我尝试运行测试时,出现错误:

Org.Openqa.selenium.WebDriverException:处理命令时出现未知的服务器端错误。原始错误:com.onoapps.ome.dev前缀为io.appium.uiautomator2.common.exceptions.UiAutomator2Exception:的命名空间尚未声明。

有人知道问题出在哪里吗?

我正在使用:

  • 小米MiBox。
  • Java
  • Appium
  • JUnit

这就是我想要做的。

        public class RemoteControl extends AppiumBaseClass {

            public RemoteControl(AppiumDriver driver) {
                PageFactory.initElements(new AppiumFieldDecorator(driver), this);
            }

            @AndroidFindBy(xpath = "//com.onoapps.some.dev:id/topRootId[@focusable='true']")
            private MobileElement currentTab;

            public String getCurrentTabName() {
                MobileElement tabText = currentTab.findElement(By.id("com.onoapps.some.dev:id/topBarItemTextViewId"));
                return tabText.getText();
            }
        }

        public class SeriesScreenFlows extends BaseTestClass {
            public void getSeriesTab(){
        getCurrentTabName();
            }
        }

        public class BaseTestClass extends AppiumBaseClass {

            public WebDriverWait wait;
            public Series_screen series_screen;
            public RemoteControl remoteControl;


            @Before
            public void setUp() throws MalformedURLException {
                AppiumController.instance.start();
                series_screen = new Series_screen(driver());
                remoteControl = new RemoteControl(driver());
            }
        }

推荐答案

当您找到MobileElementID时,您不需要包括应用程序包,因此请更改此行:

MobileElement tabText = currentTab.findElement(By.id("com.onoapps.some.dev:id/topBarItemTextViewId"));

至此

MobileElement tabText = currentTab.findElement(By.id("topBarItemTextViewId"));

您的测试应该会按预期开始工作。

或者,如果要使用XPath

MobileElement tabText = currentTab.findElement(By.xpath("//*[@id='com.onoapps.some.dev:id/topBarItemTextViewId']"));

详细信息:AS - Run your existing Appium tests

这篇关于获取io.appium.uiautomator2.common.exceptions.UiAutomator2Exception错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆