...11import org.openqa.selenium.NoSuchElementException;12import org.openqa.selenium.Point;13import org.openqa.selenium.WebDriver;14import org.openqa.selenium.WebElement;15import org.openqa.selenium.interactions.Pause;16import org.openqa.selenium.interactions.PointerInput;17import org.openqa.selenium.interactions.PointerInput.Kind;18import org.openqa.selenium.interactions.PointerInput.MouseButton;19import org.openqa.selenium.interactions.PointerInput.Origin;20import org.openqa.selenium.interactions.Sequence;21import org.openqa.selenium.remote.DesiredCapabilities;22import org.openqa.selenium.support.ui.WebDriverWait;23import io.appium.java_client.functions.ExpectedCondition;24import io.appium.java_client.ios.IOSDriver;25public class Edition116_iOS_Springboard {26 private IOSDriver<WebElement> driver;27 private WebDriverWait wait;28 private final static String SPRINGBOARD = "com.apple.springboard";29 private int curPage;30 @Before31 public void setUp() throws MalformedURLException {32 DesiredCapabilities capabilities = new DesiredCapabilities();33 capabilities.setCapability("platformName", "iOS");34 capabilities.setCapability("platformVersion", "13.3");35 capabilities.setCapability("deviceName", "iPhone 11");36 capabilities.setCapability("app", SPRINGBOARD);37 capabilities.setCapability("autoLaunch", false);38 capabilities.setCapability("automationName", "XCUITest");39 driver = new IOSDriver<WebElement>(new URL("http://localhost:4723/wd/hub"), capabilities);40 wait = new WebDriverWait(driver, 10);41 }42 @After43 public void tearDown() {44 if (driver != null) {45 driver.quit();46 }47 }48 @Test49 public void testSpringboard() {50 wait.until(AppIconPresent("Reminders")).click();51 pressHome();52 wait.until(AppIconPresent("Contacts")).click();53 pressHome();54 }55 protected void swipe(Point start, Point end, Duration duration) {56 PointerInput input = new PointerInput(Kind.TOUCH, "finger1");57 Sequence swipe = new Sequence(input, 0);58 swipe.addAction(input.createPointerMove(Duration.ZERO, Origin.viewport(), start.x, start.y));59 swipe.addAction(input.createPointerDown(MouseButton.LEFT.asArg()));60 swipe.addAction(new Pause(input, duration));61 duration = Duration.ZERO;62 swipe.addAction(input.createPointerMove(duration, Origin.viewport(), end.x, end.y));63 swipe.addAction(input.createPointerUp(MouseButton.LEFT.asArg()));64 driver.perform(ImmutableList.of(swipe));65 }66 protected void swipe(double startXPct, double startYPct, double endXPct, double endYPct, Duration duration) {67 Dimension size = driver.manage().window().getSize();68 Point start = new Point((int)(size.width * startXPct), (int)(size.height * startYPct));69 Point end = new Point((int)(size.width * endXPct), (int)(size.height * endYPct));70 swipe(start, end, duration);71 }72 protected void pressHome() {73 driver.executeScript("mobile: pressButton", ImmutableMap.of("name", "home"));74 }...