appium服务器无限期暂停,尝试按文本查找元素

问题描述

我正在使用appium在android应用上进行自动化测试

这是当前屏幕:

enter image description here

这是代码

new TouchAction(driver).longPress(PointOption.point(720,1919)).moveto(PointOption.point(720,180)).release().perform();
 Thread.sleep(5000);
 
 By folder = By.xpath("//*[@text='ads']");
 
 outer:
 for(int i = 0; i < 1000000000; i++) {
     
     try {
         
         driver.findElement(folder).click();
         Thread.sleep(1000);
         
         break;
         
     } catch(org.openqa.selenium.NoSuchElementException e) {
         
         continue outer;
         
     }
     
 }

这是appium服务器:

[HTTP] --> POST /wd/hub/session/7924f3c3-f873-491b-8466-6940b15f1dd9/element [HTTP] {"using":"xpath","value":"//*[@text='ads']"}   
[debug] [W3C (7924f3c3)] Calling AppiumDriver.findElement() with args: ["xpath","//*[@text='ads']","7924f3c3-f873-491b-8466-6940b15f1dd9"] 
[debug] [BaseDriver] Valid locator strategies for this request: xpath,id,class name,accessibility id,-android uiautomator
 [debug] [BaseDriver] Waiting up to 0 ms for condition 
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//*[@text='ads']","context":"","multiple":false}} 
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] 
[debug] Got data from client: {"cmd":"action","multiple":false}} 
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] 
[debug] Got command of type ACTION 
[debug] [AndroidBootstrap] [BOOTSTRAP LOG]
[debug] Got command action: find
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] 
[debug] Finding '//*[@text='ads']' using 'XPATH' with the contextId: '' multiple: false

除非我进入并触摸屏幕并“帮助” appium查找元素,否则appium服务器将无限期保持这种状态

还有其他查找元素的方法,但是在此测试用例中,通过文本查找元素是最可靠的,因此id希望坚持下去

有人可以帮忙吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)