【发布时间】:2014-07-03 00:15:50
【问题描述】:
我是这个论坛和 appium/android 自动化的新手,在采取下一步行动之前,我需要帮助来验证我的应用中是否存在对象。
我尝试使用下面的代码,但甚至没有达到我的第二个打印语句。
@Test
public void addContact() {
System.out.println( "Checking if Contact exists.... 111111 ");
WebElement e = driver.findElement(By.name("John Doe"));
System.out.println( "Checking if Contact exists.... 222222");
boolean contactExists = e.isDisplayed();
System.out.println( contactExists );
if (contactExists == true) {
System.out.println( "Contact exists.... ");
} else {
System.out.println( "Contact DOES NOT exists.... ");
}
}
在此处运行此代码是 appium 控制台输出...它只是不断循环通过此代码并且脚本失败。
info: [BOOTSTRAP] [info] 得到了 ACTION 类型的命令
info: [BOOTSTRAP] [debug] Got command action: find
info: [BOOTSTRAP] [debug] 使用 NAME 和 contextId 查找 John Doe:
info: [BOOTSTRAP] [info] 返回结果:{"value":"No element found","status":7}
信息:将命令推送到 appium 工作队列:["find",{"strategy":"name","selector":"John Doe","context":"","multiple":false}]
info: [BOOTSTRAP] [info] 从客户端获取数据:{"cmd":"action","action":"find","params":{"strategy":"name","selector": "John Doe","context":"","multiple":false}}
isDisplayed 是正确的方法还是有更好的替代方法?
干杯.... TIA
【问题讨论】: