List of usage examples for org.openqa.selenium WebDriver quit
void quit();
From source file:org.jboss.arquillian.drone.factory.WebDriverFactory.java
License:Apache License
public void destroyInstance(WebDriver instance) { instance.quit(); }
From source file:org.jboss.arquillian.drone.webdriver.factory.WebDriverFactory.java
License:Apache License
@SuppressWarnings("unchecked") @Override// w w w . j a v a2 s . com public void destroyInstance(WebDriver instance) { // check if there is a better destructor than default one // FIXME: this line should be written generally, not only for subclasses of RemoteWebDriver Class<?> instanceClass = instance instanceof RemoteWebDriver ? RemoteWebDriver.class : instance.getClass(); @SuppressWarnings("rawtypes") Destructor destructor = null; try { destructor = registryInstance.get().getEntryFor(instanceClass, Destructor.class); } catch (Exception ignored) { } if (destructor != null && !destructor.getClass().equals(this.getClass())) { destructor.destroyInstance(instance); } else { instance.quit(); } }
From source file:org.jboss.arquillian.graphene.context.TestGrapheneProxyHandler.java
License:Open Source License
@Test public void test_webDriver_methods_which_should_not_return_proxy() { IsNotProxyable isNotProxyable = new IsNotProxyable(); // when/* ww w .j a v a2 s . c om*/ WebDriver driver = Mockito.mock(WebDriver.class, isNotProxyable); Options options = mock(Options.class, isNotProxyable); Navigation navigation = mock(Navigation.class, isNotProxyable); ImeHandler ime = mock(ImeHandler.class, isNotProxyable); Logs logs = mock(Logs.class, isNotProxyable); // then try { driver.toString(); driver.close(); driver.equals(new Object()); driver.get(""); driver.getClass(); driver.getCurrentUrl(); driver.getPageSource(); driver.getTitle(); driver.getWindowHandle(); driver.hashCode(); driver.quit(); driver.toString(); options.addCookie(mock(Cookie.class)); options.deleteAllCookies(); options.deleteCookie(mock(Cookie.class)); options.deleteCookieNamed(""); options.getCookieNamed(""); navigation.back(); navigation.forward(); navigation.to(""); navigation.to(new URL("http://localhost/")); ime.activateEngine(""); ime.deactivate(); ime.getActiveEngine(); ime.isActivated(); logs.get(""); } catch (Exception e) { throw new RuntimeException(e); } assertEquals(Arrays.asList(), isNotProxyable.getViolations()); }
From source file:org.jboss.arquillian.selenium.instantiator.WebDriverInstantiator.java
License:Apache License
public void destroy(WebDriver instance) { instance.quit(); }
From source file:org.jitsi.meet.test.ConferenceFixture.java
License:Apache License
/** * Hangs up the Jitsi-Meet call running in {@code participant} and closes * the driver./*from w w w. ja v a2s . com*/ * @param participant the participant. * @param hangup whether we need to hangup the call first */ public static void quit(WebDriver participant, boolean hangup) { if (hangup) close(participant); try { participant.quit(); TestUtils.waitMillis(500); } catch (Throwable t) { t.printStackTrace(); } String instanceName = getParticipantName(participant); System.err.println("Closed " + instanceName + "."); if (participant == owner) { owner = null; } else if (participant == secondParticipant) { secondParticipant = null; } else if (participant == thirdParticipant) { thirdParticipant = null; } }
From source file:org.kurento.room.test.RoomTest.java
License:Open Source License
protected void closeBrowsers() { if (!browsersClosed && browsers != null && !browsers.isEmpty()) { for (WebDriver browser : browsers) if (browser != null) try { browser.close();//from w w w. j a va2 s . c o m browser.quit(); } catch (Exception e) { log.warn("Error closing browser", e); fail("Unable to close browser: " + e.getMessage()); } browsersClosed = true; } }
From source file:org.lunifera.example.vaadin.osgi.testpart.TextFieldPartTest.java
License:Apache License
@Test public void test() { WebDriver driver = new FirefoxDriver(); // And now use this to visit Google driver.get("http://www.google.com"); // Alternatively the same thing can be done like this // driver.navigate().to("http://www.google.com"); // Find the text input element by its name WebElement element = driver.findElement(By.name("q")); // Enter something to search for element.sendKeys("Cheese!"); // Now submit the form. WebDriver will find the form for us from the // element//from w w w.ja v a2 s . c o m element.submit(); // Check the title of the page System.out.println("Page title is: " + driver.getTitle()); // Should see: "cheese! - Google Search" System.out.println("Page title is: " + driver.getTitle()); // Close the browser driver.quit(); }
From source file:org.me.seleniumGridUI.SeleniumStatus.java
public String getEnvironment() throws Throwable { if (IsThisDeviceTesting()) { return StringUtils.EMPTY; }// w w w . j a v a 2 s . co m Map<String, String> myMap = new HashMap<String, String>(); SeleniumGridOperation seleniumOperation = SeleniumGridOperation.getInstance(); WebDriver driver = new RemoteWebDriver(new URL(hubUrl), seleniumOperation.CreateBrowserCapbility("phantomjs")); driver.get("http://www.autoscout24.de/build.txt"); String siteContent = driver.findElement(By.tagName("pre")).getText(); if (driver != null) { driver.quit(); } String[] elements = siteContent.split("\\n"); for (String s1 : elements) { s1 = s1.replaceAll("\\s", ""); String[] keyValue = s1.split(":"); myMap.put(keyValue[0], keyValue[1]); } return myMap.get("Environment"); }
From source file:org.metawidget.util.ScenarioRunnerTestCase.java
License:LGPL
/** * Run the Scenario Runner by hitting the given URL and waiting until all tests complete. *//*ww w . j a v a2 s.c o m*/ protected final void runScenarioRunner(String url) { WebDriver driver = new FirefoxDriver(); try { // Hit the url driver.get(url); // Wait for all scenario runner tests to run, and fail on error new WebDriverWait(driver, TEST_TIMEOUT_IN_SECONDS).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver theDriver) { return applyExpectedCondition(theDriver); } }); displayResult(driver); } finally { driver.quit(); } }
From source file:org.mifos.server.wartest.MifosPackagedWARBasicTest.java
License:Open Source License
@Test public void testPackagedWARStartup() throws Exception { WARServerLauncher serverLauncher = mifosLauncher(7077); serverLauncher.startServer();/*from w w w . java2 s. co m*/ WebDriver wd = new FirefoxDriver(); wd.get("http://localhost:7077/mifos/"); wd.findElement(By.id("login.input.username")).sendKeys("mifos"); wd.findElement(By.id("login.input.password")).sendKeys("testmifos"); wd.findElement(By.id("login.button.login")).click(); Assert.assertTrue(wd.getPageSource().contains("Mifos")); Assert.assertTrue(wd.getPageSource().contains("Home")); Assert.assertTrue(wd.getPageSource().contains("Search")); wd.quit(); serverLauncher.stopServer(); serverLauncher = null; }