gpt4 book ai didi

appium - 如何将元素滚动到适用于 iOS 的 appium 1.7 中的特定位置

转载 作者:行者123 更新时间:2023-12-04 14:25:09 26 4
gpt4 key购买 nike

下面的代码可以滚动到结束,但我不想滚动到结束我想滚动某个特定位置:

driver.findElementByXPath("//*[@value='UpcomingInstallations']").click();
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "down");
js.executeScript("mobile: scroll", scrollObject);

最佳答案

我这样做的方法是在屏幕上寻找元素 ( https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/WebElement.html#isDisplayed-- ),如果我没有看到它,请滑动。

while (!displayed)
swipe

我建议您查看用于滑动的 TouchAction 类:https://appium.github.io/java-client/io/appium/java_client/TouchAction.html .首选的滑动方法如下:

myTouchAction.press(startX,startY).moveTo(endX,endY).release().perform()

由于设备之间的像素可能不同,因此您需要使用基于总屏幕尺寸百分比的坐标。参见 https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/WebDriver.Window.html#getSize--想要查询更多的信息。

关于appium - 如何将元素滚动到适用于 iOS 的 appium 1.7 中的特定位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47472597/

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