[Selenium] Android 中旋转屏幕,触摸,滚动

package com.learingselenium.android;

import junit.framework.TestCase

import org.openqa.selenium.Rotatable;

 import org.openqa.selenium.ScreenOrientation;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.android.AndroidDriver;

import org.openqa.selenium.interactions.touch.TouchActions;

...

WebDriver driver = new AndroidDriver("http://localhost:8888/wd/hub");

((Rotatable) driver).rotate(ScreenOrientation.LANDSCAPE);  //旋转屏幕

driver.get("http://1.com");

driver.close();

...

WebDriver driver = new AndroidDriver("http://localhost:8888/wd/hub");

driver.get("http://1.com");

((Rotatable) driver).rotate(ScreenOrientation.PORTRAIT); //确保屏幕方向为 PORTRAIT

//向下滚动400个像素偏移量

TouchActions touch = new TouchActions(driver);

touch.scroll(0, 400).build().perform();  

driver.close();

...

原文地址:https://www.cnblogs.com/feifeidxl/p/4560965.html