gpt4 book ai didi

android - Appium - 如何验证一个对象是否存在

转载 作者:行者123 更新时间:2023-11-29 00:18:47 25 4
gpt4 key购买 nike

我是这个论坛和 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] Got command of type ACTION

info: [BOOTSTRAP] [debug] Got command action: find

info: [BOOTSTRAP] [debug] Finding John Doe using NAME with the contextId:

info: [BOOTSTRAP] [info] Returning result: {"value":"No element found","status":7}

info: Pushing command to appium work queue: ["find",{"strategy":"name","selector":"John Doe","context":"","multiple":false}]

info: [BOOTSTRAP] [info] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"John Doe","context":"","multiple":false}}

isDisplayed 在这里是正确的方法还是有更好的替代方法?

干杯......TIA

最佳答案

如果您使用的是 Appium 1.0+

  • By.name 定位策略已被弃用。请使用一些其他的东西,如 By.xpath 等。

关于android - Appium - 如何验证一个对象是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24543079/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com