在iOS滚动时,元素清单在发抖

发布于 2025-02-12 14:10:09 字数 974 浏览 0 评论 0原文

我正在尝试滚动我的国家列表以找到特定的国家,在第一次尝试列表之后,它会摇晃,这提供了错误。

带有应用程序行为的视频:

1

代码:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰之心 2025-02-19 14:10:09

我认为您正在使用的滚动只是滑动,因此并不能真正控制。另外,当您进行findelementbyxyz时,我认为在搜索屏幕外的东西时,有5​​0个元素的限制,因此,如果您在滚动后以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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文