【发布时间】:2016-10-15 22:11:56
【问题描述】:
我的 Android 应用中有一个复选框列表,我需要对其进行测试。因此,当我使用 isSelected() 方法时,无论是否选中此复选框,它总是返回 false。 试图使用 findelementById() 和 byXpath()。结果相同。
这是我使用的部分代码:
WebElement checkBox = driver.findElementById(appType + id);
if (!checkBox.isSelected()){
Reporter.log(backupDataType + " checkbox isn't checked. clicking on it...", true);
...}
使用 Xpath:
checkBox = driver.findElementByXPath("//android.widget.CheckBox[@resource-id='" + appType + checkSms + "']");
if (!driver.findElementByXPath("//android.widget.CheckBox[@resource-id='" + appType + checkSms + "']").isSelected()){
Reporter.log(backupDataType + " checkbox isn't checked. clicking on it...", true);
...}
元素的路径是正确的,因为它总是在点击它。没关系,是否检查。
【问题讨论】:
标签: android selenium automation appium