java - 获取 io.appium.uiautomator2.common.exceptions.UiAutomator2Exception 错误
问题描述
我为 Android TV 流媒体应用程序编写自动化程序,运行测试时遇到问题。当我尝试运行 test 时,出现错误:
org.openqa.selenium.WebDriverException:处理命令时发生未知的服务器端错误。原始错误:io.appium.uiautomator2.common.exceptions.UiAutomator2Exception:java.lang.IllegalArgumentException:尚未声明前缀为“com.onoapps.some.dev”的命名空间。
有谁知道问题是什么?
我在用着:
- 小米盒子。
- 爪哇
- 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());
}
}
解决方案
当您通过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']"));
推荐阅读
- c++ - C ++获取两个分隔符之间的字符串并替换它
- nativescript - Nativescript Sidekick 云构建错误 Android
- google-apps-script - 使用 Session.getActiveUser().getEmail() 的共享脚本冲突
- amazon-web-services - 安装 IIS 管理器后,是否必须重新启动才能停止默认网站并启动新网站?
- awk - 使用 awk / sed 更改特定列的值
- c# - C# 组合两个图像 - 缩放
- python - 可以打印或检查有多少数据库连接请求打开以及是否关闭?django
- c# - 如何在 MassTransist 上显示总线配置
- javascript - 二叉树 - 深度优先遍历
- postgresql - rows_where 参数未传递给 pgr_nodenetwork