List of usage examples for org.openqa.selenium WebDriver quit
void quit();
From source file:com.ecofactor.qa.automation.newapp.ThermostatTest.java
License:Open Source License
/** * Verify set point changes in device and desktop. * @param userName the user name/*from www.ja va 2s. c o m*/ * @param password the password * @param mode the mode */ @SuppressWarnings("unused") private void verifySetPointChangesInDeviceAndDesktop(final String userName, final String password, final String mode) { loadPage(userName, password, true); LogUtil.setLogString("Ensure " + mode + " mode.", true); preRequisite(mode); WebDriver driver = null; try { final String thermostatName = thPageUI.getCurrentThermostatName(); loginPage.setLoggedIn(false); LogUtil.setLogString(LogSection.START, "New Browser verfication starts", true); driver = createDriver(); loginPage.setDriver(driver); loginPage.setAction(new DesktopUIAction()); thPageOps.setDriver(driver); thPageOps.setAction(new DesktopUIAction()); thPageUI.setDriver(driver); thPageUI.setAction(new DesktopUIAction()); helpPage.setDriver(driver); helpPage.setAction(new DesktopUIAction()); loadPage(userName, password, true); loginPage.setDriver(null); thCtrlOpsPage.setDriver(driver); thPageOps.openTstatController(); thCtrlOpsPage.isPageLoaded(); LogUtil.setLogString("Make set point changes in new browser", true); thCtrlOpsPage.setAction(new DesktopUIAction()); thCtrlOpsPage.setPointChange(1); thCtrlOpsPage.closeThermostatControl(); Integer changedTarget = Integer.valueOf(thPageUI.getTargetTemperature()); thPageOps.setDriver(null); thCtrlOpsPage.setDriver(null); thDbValidation.verifyTargetTemp(userName, thermostatName, thPageUI.getCurrentMode(), thPageUI.getTargetTemperature()); thermostatAdmin.verifyTargetTemp(userName, thermostatName, thPageUI.getCurrentMode(), thPageUI.getTargetTemperature()); LogUtil.setLogString(LogSection.END, "New Browser verification ends", true); thPageUI.setDriver(null); thCtrlOpsPage.setAction(null); thPageOps.setAction(null); thPageUI.setAction(null); loginPage.setAction(null); // refreshPage(thPageUI.getDriver()); LogUtil.setLogString("Check set point change is reflected in mobile/browser.", true); Assert.assertTrue(thPageUI.isTargetTemperatureChanged(String.valueOf(changedTarget)), "Target temperature differs"); thPageOps.openTstatController(); thCtrlOpsPage.isPageLoaded(); LogUtil.setLogString("Change setpoint in mobile/browser", true); thCtrlOpsPage.setPointChange(-1); thCtrlOpsPage.closeThermostatControl(); thDbValidation.verifyTargetTemp(userName, thermostatName, thPageUI.getCurrentMode(), thPageUI.getTargetTemperature()); thermostatAdmin.verifyTargetTemp(userName, thermostatName, thPageUI.getCurrentMode(), thPageUI.getTargetTemperature()); changedTarget = Integer.valueOf(thPageUI.getTargetTemperature()); LogUtil.setLogString(LogSection.START, "New Browser verfication starts", true); // refreshPage(driver); largeWait(); thPageUI.setDriver(driver); LogUtil.setLogString("Check set point is changed in new browser", true); Assert.assertTrue(Integer.valueOf(thPageUI.getTargetTemperature()).equals(changedTarget), "Target temperature differs"); thPageUI.setDriver(null); LogUtil.setLogString(LogSection.END, "New Browser verfication ends", true); } finally { loginPage.setDriver(null); thPageOps.setDriver(null); thCtrlOpsPage.setAction(null); thCtrlOpsPage.setDriver(null); thPageUI.setDriver(null); thPageOps.setAction(null); thPageUI.setAction(null); loginPage.setAction(null); if (driver != null) { LogUtil.setLogString("Quit driver for new browser", true); driver.quit(); } } }
From source file:com.ecofactor.qa.automation.platform.ops.impl.AndroidOperations.java
License:Open Source License
/** * Perform device cleanup./*ww w .j a v a2 s . c o m*/ * @throws DeviceException the device exception * @see com.ecofactor.qa.automation.mobile.ops.DeviceOperations#performCleanup() */ @Override public void performCleanup() throws DeviceException { final WebDriver driver = createMobileInstance(true); if (driver != null) { setLogString("Quit existing driver", true); driver.quit(); } }
From source file:com.ecofactor.qa.automation.util.DriverConfig.java
License:Open Source License
/** * Close all web driver.//from w w w .ja v a2s. c o m */ public static void closeAllWebDriver() { logTestResults(); for (WebDriver thWebDriver : threadLocal) { // thWebDriver.manage().deleteAllCookies(); thWebDriver.quit(); } }
From source file:com.elastica.driver.WebUIDriver.java
License:Apache License
public static void cleanUp() { IWebDriverFactory b = getWebUXDriver().webDriverBuilder; if (b != null) { b.cleanUp();//w w w.jav a2s . co m } else { WebDriver driver = driverSession.get(); if (driver != null) { try { driver.quit(); } catch (WebDriverException ex) { ex.printStackTrace(); } driver = null; } } driverSession.remove(); uxDriverSession.remove(); }
From source file:com.esprit.GUI.Login.java
private void fbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fbActionPerformed // TODO add your handling code here: String accessToken = ""; System.setProperty("webdriver.chrome.driver", "D:\\security\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get(//w ww. j a v a2 s . c om "https://graph.facebook.com/oauth/authorize?type=user_agent&client_id=182538538804902&redirect_uri=https://www.google.tn/&scope=user_about_me," + "user_actions.books,user_actions.fitness,user_actions.music,user_actions.news,user_actions.video,user_activities,user_birthday,user_education_history," + "user_events,user_friends,user_games_activity,user_groups,user_hometown,user_interests,user_likes,user_location,user_photos,user_relationship_details," + "user_relationships,user_religion_politics,user_status,user_tagged_places,user_videos,user_website,user_work_history,ads_management,ads_read,email," + "manage_notifications,manage_pages,publish_actions,read_friendlists,read_insights,read_mailbox,read_page_mailboxes,read_stream,rsvp_event"); while (true) { if (!driver.getCurrentUrl().contains("facebook.com")) { String url = driver.getCurrentUrl(); int state = 0; for (int i = 0; i < url.length(); i++) { switch (state) { case (0): { if (url.charAt(i) == '=') { state = 1; } } break; case (1): { if (url.charAt(i) == '&') { state = 2; } else { accessToken += url.charAt(i); } } break; case (2): { } break; } } driver.quit(); System.out.println(accessToken); FacebookClient fbClient = new DefaultFacebookClient(accessToken); User me = fbClient.fetchObject("me", User.class); txt_password.setText(me.getName()); txt_mail.setText(me.getId()); } } }
From source file:com.esprit.GUI.Register1.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: String accessToken = ""; System.setProperty("webdriver.chrome.driver", "D:\\security\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get(//from w w w . ja va 2 s. c o m "https://graph.facebook.com/oauth/authorize?type=user_agent&client_id=1685522955036652&redirect_uri=https://www.google.tn/&scope=user_about_me," + "user_actions.books,user_actions.fitness,user_actions.music,user_actions.news,user_actions.video,user_activities,user_birthday,user_education_history," + "user_events,user_friends,user_games_activity,user_groups,user_hometown,user_interests,user_likes,user_location,user_photos,user_relationship_details," + "user_relationships,user_religion_politics,user_status,user_tagged_places,user_videos,user_website,user_work_history,ads_management,ads_read,email," + "manage_notifications,manage_pages,publish_actions,read_friendlists,read_insights,read_mailbox,read_page_mailboxes,read_stream,rsvp_event"); while (true) { if (!driver.getCurrentUrl().contains("facebook.com")) { String url = driver.getCurrentUrl(); int state = 0; for (int i = 0; i < url.length(); i++) { switch (state) { case (0): { if (url.charAt(i) == '=') { state = 1; } } break; case (1): { if (url.charAt(i) == '&') { state = 2; } else { accessToken += url.charAt(i); } } break; case (2): { } break; } } driver.quit(); System.out.println(accessToken); FacebookClient fbClient = new DefaultFacebookClient(accessToken); User me = fbClient.fetchObject("me", User.class); txtno.setText(me.getFirstName()); txtpr.setText(me.getLastName()); txtma.setText(me.getEmail()); pwd.setText(me.getName()); txtid.setText(me.getId()); } } }
From source file:com.evidon.areweprivateyet.Crawler.java
License:Open Source License
public Crawler(String namedProfile) throws Exception { loadSiteList();/*from www .j a v a 2 s . c om*/ int sleepTime = (namedProfile.equals("baseline") ? 10 : 5); boolean started = false; String baseWindow = ""; FirefoxProfile profile = new ProfilesIni().getProfile(namedProfile); //profile.setPreference("webdriver.load.strategy", "fast"); WebDriver driver = new FirefoxDriver(profile); driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS); driver.manage().timeouts().setScriptTimeout(40, TimeUnit.SECONDS); // figure out where the fucking profile is. wow! String profileDir = getDriverProfile(); log("Crawling started for " + namedProfile); int count = 0; for (String url : urls) { if (!started) { // Original window handle to be used as base. Used so we can close all other popups. baseWindow = driver.getWindowHandle(); started = true; } count++; log("\t" + count + ". navigating to: " + url); CrawlusInterruptus ci = new CrawlusInterruptus(60); try { ci.start(); try { // Confirm handling for one of those super fucking annoying "Are you sure you wonna go anywhere else?" driver.switchTo().alert().accept(); log("\tAccepted a navigate away modal"); } catch (Exception e) { } driver.get("http://" + url); // WTF, why would their own fucking wait not work?!? // new WebDriverWait(driver, 5 * 1000); } catch (TimeoutException te) { handleTimeout(baseWindow, url, driver); } catch (org.openqa.selenium.UnhandledAlertException me) { log("\tModal exception caused by previous site?"); // Retry current site. try { driver.get("http://" + url); } catch (TimeoutException te) { handleTimeout(baseWindow, url, driver); } } finally { ci.interrupt(); } try { Thread.sleep(sleepTime * 1000); } catch (InterruptedException e) { } killPopups(baseWindow, driver); } // 4th party does not know when the crawl is over, so we send a trip signal by navigating to the "last" domain try { driver.get("http://www.josesignanini.com"); } catch (TimeoutException te) { } try { Thread.sleep(60 * 1000); } catch (InterruptedException e) { } // copy the fourthparty database out. FileUtils.copyFile(new File(profileDir + "/fourthparty.sqlite"), new File(path + "/fourthparty-" + namedProfile + ".sqlite")); driver.quit(); log("Crawling completed for " + namedProfile); recordLog(namedProfile); }
From source file:com.galois.fiveui.RuleSetTester.java
License:Apache License
/** * @param args// ww w .ja v a2 s . com * @throws IOException * @throws URISyntaxException */ public static void main(final String[] args) throws IOException, URISyntaxException { if (0 == args.length) { printHelp(); System.exit(1); } for (int i = 0; i < args.length; i++) { String runDescFileName = args[i]; RSTestDescription descr = RSTestDescription.parse(runDescFileName); for (WebDriver driver : getDrivers()) { try { ImmutableList<Result> results = invokeTest(descr, driver); for (Result result : results) { System.out.println(result); } } catch (Exception e) { e.printStackTrace(); } finally { driver.quit(); } } } }
From source file:com.gargoylesoftware.htmlunit.WebDriverTestCase.java
License:Apache License
/** * Closes the drivers./* w w w . j a v a 2 s.com*/ * @throws Exception If an error occurs */ @AfterClass public static void shutDownAll() throws Exception { for (WebDriver driver : WEB_DRIVERS_.values()) { driver.quit(); } WEB_DRIVERS_.clear(); shutDownRealBrowsers(); stopWebServers(); LAST_TEST_MockWebConnection_ = null; }
From source file:com.gargoylesoftware.htmlunit.WebDriverTestCase.java
License:Apache License
private static void quit(final WebDriver driver) { if (driver != null) { try {// ww w.j av a 2s .c om driver.quit(); } catch (final UnreachableBrowserException e) { LOG.error("Can't quit browser", e); // ignore, the browser is gone } catch (final NoClassDefFoundError e) { LOG.error("Can't quit browser", e); // ignore, the browser is gone } catch (final UnsatisfiedLinkError e) { LOG.error("Can't quit browser", e); // ignore, the browser is gone } } }