@After public void tearDown() { if (driver != null) { driver.quit(); } driver = null; }
/** * finishing. */ @AfterClass public static void afterClass() { if (driver != null) { driver.quit(); } if (service != null) { service.stop(); } }
@Override public void destroyInstance(AppiumDriver instance) { instance.quit(); }
@After public void tearDown() { try { driver.quit(); } catch (Exception ign) {} }
@After public void tearDown() { try { driver.quit(); } catch (Exception ign) {} }
@After public void tearDown() { try { driver.quit(); } catch (Exception ign) {} }
public static void dispose() { if (mobileDriver == null) { return; } try { mobileDriver.quit(); } finally { setMobileDriver(null); } }
@Override public void stop() { log.info("Stopping mobile testing session to device: " + getDeviceDescription()); driver.quit(); }
@After public void tearDown() { try { driver.quit(); } catch (Exception ign) {} }
@After public void tearDown() { try { driver.quit(); } catch (Exception ign) {} }
private void quitApp () { final String message = "Closing & Quitting [%s] device driver..."; LOG.trace (format (message, this.platform)); try { this.driver.closeApp (); this.driver.quit (); } catch (final NoSuchSessionException e) { fail (AppiumServerStoppedError.class, SERVER_STOPPED, e); } catch (final Exception e) { fail (DeviceDriverNotStoppingError.class, "Error occured while stopping device driver.", e); } }
@After public void stopDriver() { this.driver.quit(); }
public static void appRelaunch(){ log.info("Restart app..."); try { //TODO: driver.quit() is needed or not? driver.quit(); if(Util.isAndroid()) { Driver.prepareForAppiumAndroid(ConfigUtil.getPackageName(), ConfigUtil.getActivityName(), ConfigUtil.getUdid(), ConfigUtil.getPort()); }else{ Driver.prepareForAppiumIOS(ConfigUtil.getBundleId(), ConfigUtil.getUdid(), ConfigUtil.getPort(), ConfigUtil.getWdaPort()); } Driver.sleep(APP_START_WAIT_TIME); }catch (Exception e){ log.error("Fail to relaunch app"); e.printStackTrace(); } }
public void actualTest(AppiumDriver driver) { WebDriverWait wait = new WebDriverWait(driver, 10); try { wait.until(ExpectedConditions.presenceOfElementLocated(loginScreen)).click(); wait.until(ExpectedConditions.presenceOfElementLocated(username)).sendKeys(AUTH_USER); wait.until(ExpectedConditions.presenceOfElementLocated(password)).sendKeys(AUTH_PASS); wait.until(ExpectedConditions.presenceOfElementLocated(loginBtn)).click(); } finally { driver.quit(); } } }
public void actualTest(AppiumDriver driver) { // Set up default wait WebDriverWait wait = new WebDriverWait(driver, 10); try { driver.get("http://appiumpro.com/contact"); wait.until(ExpectedConditions.visibilityOfElementLocated(EMAIL)) .sendKeys("foo@foo.com"); driver.findElement(MESSAGE).sendKeys("Hello!"); driver.findElement(SEND).click(); String response = wait.until(ExpectedConditions.visibilityOfElementLocated(ERROR)).getText(); // validate that we get an error message involving a captcha, which we didn't fill out Assert.assertThat(response, CoreMatchers.containsString("Captcha")); } finally { driver.quit(); } } }
public void actualTest(AppiumDriver driver) { WebDriverWait wait = new WebDriverWait(driver, 10); try { driver.get("https://appiumpro.com/test"); // click the link wait.until(ExpectedConditions.presenceOfElementLocated(link)).click(); // assert we navigated as expected wait.until(ExpectedConditions.urlToBe("https://appiumpro.com/")); } finally { driver.quit(); } } }
private void runStepByStepTest(AppiumDriver driver, Model model) { WebDriverWait wait = new WebDriverWait(driver, 10); try { wait.until(ExpectedConditions.presenceOfElementLocated(model.loginScreen)).click(); wait.until(ExpectedConditions.presenceOfElementLocated(model.username)).sendKeys(AUTH_USER); wait.until(ExpectedConditions.presenceOfElementLocated(model.password)).sendKeys(AUTH_PASS); wait.until(ExpectedConditions.presenceOfElementLocated(model.loginBtn)).click(); wait.until(ExpectedConditions.presenceOfElementLocated(model.getLoggedInBy(AUTH_USER))); } finally { driver.quit(); } }
private void runDeepLinkTest(AppiumDriver driver, Model model) { WebDriverWait wait = new WebDriverWait(driver, 10); try { driver.get("theapp://login/" + AUTH_USER + "/" + AUTH_PASS); wait.until(ExpectedConditions.presenceOfElementLocated(model.getLoggedInBy(AUTH_USER))); } finally { driver.quit(); } }
private void automateClipboard(AppiumDriver driver) { WebDriverWait wait = new WebDriverWait(driver, 5); try { wait.until(ExpectedConditions.presenceOfElementLocated(clipboardNav)).click(); String text = "Hello World"; ((HasClipboard) driver).setClipboardText(text); wait.until(ExpectedConditions.presenceOfElementLocated(refreshClipboardBtn)).click(); By clipboardText = MobileBy.AccessibilityId(text); Assert.assertEquals(driver.findElement(clipboardText).getText(), text); text = "Hello World Again"; driver.findElement(clipboardInput).sendKeys(text); try { driver.hideKeyboard(); } catch (Exception ign) {} driver.findElement(setTextBtn).click(); Assert.assertEquals(((HasClipboard) driver).getClipboardText(), text); } finally { driver.quit(); } } }
public void actualTest(AppiumDriver driver) throws URISyntaxException, IOException { WebDriverWait wait = new WebDriverWait(driver, 10); try { // get to the photo view wait.until(ExpectedConditions.presenceOfElementLocated(photos)).click(); // wait for and click the correct image using a reference image template By sunriseImage = MobileBy.image(getReferenceImageB64()); wait.until(ExpectedConditions.presenceOfElementLocated(sunriseImage)).click(); // verify that the resulting alert proves we clicked the right image wait.until(ExpectedConditions.alertIsPresent()); String alertText = driver.switchTo().alert().getText(); Assert.assertThat(alertText, Matchers.containsString("sunrise")); } finally { driver.quit(); } } }