【问题标题】:Getting io.appium.uiautomator2.common.exceptions.UiAutomator2Exception error获取 io.appium.uiautomator2.common.exceptions.UiAutomator2Exception 错误
【发布时间】:2020-01-01 21:34:37
【问题描述】:

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

org.openqa.selenium.WebDriverException:处理命令时发生未知的服务器端错误。原始错误:io.appium.uiautomator2.common.exceptions.UiAutomator2Exception: java.lang.IllegalArgumentException: Namespace with prefix 'com.onoapps.some.dev' has not been declared。

谁知道问题出在哪里?

我正在使用:

  • 小米盒子。
  • 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());
            }
        }

【问题讨论】:

    标签: java android junit automation appium


    【解决方案1】:

    当您通过ID 找到MobileElement 时,您不需要包含您的应用程序包,因此更改此行:

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-28
      • 1970-01-01
      • 1970-01-01
      • 2018-08-17
      • 1970-01-01
      • 2011-12-19
      • 2020-04-01
      • 2014-02-17
      相关资源
      最近更新 更多