Getting io.appium.uiautomator2.common.exceptions.UiAutomator2Exception error(获取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错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:获取io.appium.uiautomator2.common.exceptions.UiAutomator2Exception错误
				
        
 
            
        基础教程推荐
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
 - Java 实例变量在两个语句中声明和初始化 2022-01-01
 - 大摇大摆的枚举 2022-01-01
 - 在 Java 中创建日期的正确方法是什么? 2022-01-01
 - 验证是否调用了所有 getter 方法 2022-01-01
 - 从 python 访问 JVM 2022-01-01
 - Java Swing计时器未清除 2022-01-01
 - 不推荐使用 Api 注释的描述 2022-01-01
 - 多个组件的复杂布局 2022-01-01
 - 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
						
						
						
						
						
				
				
				
				