下面提到的滚动方法在纵向模式下工作正常,但在横向模式下滚动方法不适用于 IOS。
Appium 版本:1.7.1
IOS版本:11.2
模拟器/真实设备:模拟器 - iPhone SE
请帮忙!!
@Test
public void ScrollWithElementByName(RemoteWebDriver driver, String XPath) throws InterruptedException
{
RemoteWebElement elements = (RemoteWebElement) driver.findElement(By.name(XPath));
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("element", ((RemoteWebElement) elements).getId());
scrollObject.put("toVisible", "true");
js.executeScript("mobile: scroll", scrollObject);
}
@Test
public void ScrollWithoutElement(RemoteWebDriver driver) throws InterruptedException
{
Dimension size = driver.manage().window().getSize();
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "down");
js.executeScript("mobile: scroll", scrollObject);
scrollObject.put("direction", "up");
js.executeScript("mobile: scroll", scrollObject);
}