我有一个滚动条,但想让它在不必一直输入x和y坐标的情况下找到元素,有办法吗?
WebElement start = androidDriver.findElement(By.id(".........")); TouchAction action = new TouchAction(androidDriver); action.longPress(start).moveTo(202,120).release().perform();
如果有两个元素,则可以使用一种无坐标滚动的替代方法。从一个元素开始滚动,到另一个元素停止滚动。这看起来像:
WebElement start = androidDriver.findElement(By.id("id_of_the_start_element")); WebElement end = androidDriver.findElement(By.id("id_of_the_end_element")); TouchAction action = new TouchAction(androidDriver); action.press(start).moveTo(end).release().perform();