简体   繁体   中英

Getting io.appium.uiautomator2.common.exceptions.UiAutomator2Exception error

I write automation for Android TV streaming app, I have problem to run the test. When I'm trying to run test , i got error:

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: io.appium.uiautomator2.common.exceptions.UiAutomator2Exception: java.lang.IllegalArgumentException: Namespace with prefix 'com.onoapps.some.dev' has not been declared.

Anyone know what the problem is?

I'm using:

  • Xiaomi miBox.
  • Java
  • Appium
  • JUnit

That's what I was trying to do.

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

You don't need to include you app package when you locate a MobileElement by ID so change this line:

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

to this

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

and your test should start working as expected.

Alternatively if you want to use XPath

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

More information: AS - Run your existing Appium tests

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM