3 回答

TA貢獻1876條經驗 獲得超5個贊
MobileElement listItem=(MobileElement)driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(text(\"<Mention your element text value here>\"))"));
您可以像這樣修改@sammar 的代碼以滾動到該元素。

TA貢獻1815條經驗 獲得超10個贊
請嘗試這個。我認為你的 UiScrollable 有問題..
MobileElement listItem=(MobileElement)driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()" + ".scrollable(true)).scrollIntoView(" + "new UiSelector().text(\"<Mention your element text value here>\"))"));

TA貢獻1876條經驗 獲得超6個贊
我使用了錯誤的元素。我不斷嘗試,終于在使用坐標后成功了。代碼如下所示。在主頁類中創建了scroll(),并從我的測試類中調用了相同的內容
public void scroll(int x, int y) {
int startY = (int) (driver.manage().window().getSize().getHeight() * 0.90);
int endY = (int) (driver.manage().window().getSize().getHeight() * 0.10);
TouchAction action = new TouchAction(driver);
action.press(point(x, startY)).waitAction(waitOptions(ofSeconds(3))).moveTo(point(x, endY)).release().perform();
}
MobileElement startElement = (MobileElement) driver.findElementById("mention parent element here");
Point location = startElement.getLocation();
homepage.scroll(location.x,location.y);
添加回答
舉報