在iOS滚动时,元素清单在发抖
我正在尝试滚动我的国家列表以找到特定的国家,在第一次尝试列表之后,它会摇晃,这提供了错误。
带有应用程序行为的视频:
代码:
public void tapOnElementByText(String element) {
HashMap<String, Object> scrollObject = new HashMap<>();
JavascriptExecutor js = driver;
scrollObject.put("direction", "down");
js.executeScript("mobile: scroll", scrollObject);
try {
driver.findElementByIosNsPredicate("label == \"" + element + "\"").click();
} catch (NoSuchElementException exception) {
System.out.println("Element not found");
}
}
我尝试了stackoverflow和appium教程的各种内容( http://appium.io/docs/docs/en/writing-rnunning - appium/tutorial/swipe-tutorial/),但这对我没有帮助
I’m trying to scroll my country list to find specific country and after first attempt list is shaking which provides error.
Video with app behaviour:
https://youtube.com/shorts/6SOI4YQbJlk?feature=share 1
Code:
public void tapOnElementByText(String element) {
HashMap<String, Object> scrollObject = new HashMap<>();
JavascriptExecutor js = driver;
scrollObject.put("direction", "down");
js.executeScript("mobile: scroll", scrollObject);
try {
driver.findElementByIosNsPredicate("label == \"" + element + "\"").click();
} catch (NoSuchElementException exception) {
System.out.println("Element not found");
}
}
I tried all kind of stuff from stackoverflow and appium tutorial(http://appium.io/docs/en/writing-running-appium/tutorial/swipe-tutorial/), but it didn’t helped me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您正在使用的滚动只是滑动,因此并不能真正控制。另外,当您进行findelementbyxyz时,我认为在搜索屏幕外的东西时,有50个元素的限制,因此,如果您在滚动后以Z开始寻找一个国家,那么仍然可能找不到。
由于您有一个搜索框,您是否可以输入所需的国家名称,甚至只是前几个字符,然后从结果缩短列表中进行选择?
我在应用程序测试中做类似的事情,并且该策略效果很好。
The scroll that you are using I think just does a swipe so isn't really controlled. Plus when you do a FindElementByXYZ I think there is a limit of 50 elements when searching for something off screen, so if you are looking for a country beginning with Z after the scroll it still might not find it.
As you have a search box could you just type in the country name you want or even just the first few characters and then select from the resulting shortened list?
I do something similar in an app I test and this strategy works well.