List of usage examples for org.openqa.selenium WebDriver close
void close();
From source file:IWDmainsiteProject.PageObjects.Verify_Pages.java
public static void Verify_partner_program(WebDriver driver) { String homePage = driver.getWindowHandle(); footer.Click_on_partner_program(driver); System.out.println("click on partner_program is done"); Set<String> windows = driver.getWindowHandles(); Iterator iterator = windows.iterator(); String currentWindowId;/*from w w w. j a v a 2 s . com*/ while (iterator.hasNext()) { currentWindowId = iterator.next().toString(); if (!currentWindowId.equals(homePage)) { driver.switchTo().window(currentWindowId); } } String actualTitle = driver.getTitle(); System.out.println(actualTitle); String expectedTitle = "IWD_Partner_Program.pdf"; assertEquals(expectedTitle, actualTitle); System.out.println("Title is correct"); String currentURL = driver.getCurrentUrl(); System.out.println(currentURL); String expectedcurrentURL = "https://www.iwdagency.com/extensions/IWD_Partner_Program.pdf"; assertEquals(currentURL, expectedcurrentURL); System.out.println("Link is correct https://www.iwdagency.com/extensions/IWD_Partner_Program.pdf"); driver.findElement(By.cssSelector(".textLayer")); System.out.println("PDF was found"); driver.close(); driver.switchTo().window(homePage); }
From source file:IWDmainsiteProject.PageObjects.Verify_Pages.java
public static void Verify_facebook(WebDriver driver) { String homePage = driver.getWindowHandle(); footer.Click_on_facebook(driver);/*from w w w .j a v a 2 s.co m*/ Set<String> windows = driver.getWindowHandles(); Iterator iterator = windows.iterator(); String currentWindowId; while (iterator.hasNext()) { currentWindowId = iterator.next().toString(); if (!currentWindowId.equals(homePage)) { driver.switchTo().window(currentWindowId); } } String actualTitle = driver.getTitle(); System.out.println(actualTitle); String expectedTitle = "IWD Agency | Facebook"; assertEquals(expectedTitle, actualTitle); System.out.println("Title is correct"); String currentURL = driver.getCurrentUrl(); System.out.println(currentURL); String expectedcurrentURL = "https://www.facebook.com/iwdagency"; assertEquals(currentURL, expectedcurrentURL); System.out.println("Link is correct https://www.facebook.com/iwdagency"); driver.close(); driver.switchTo().window(homePage); }
From source file:IWDmainsiteProject.PageObjects.Verify_Pages.java
public static void Verify_google(WebDriver driver) { String homePage = driver.getWindowHandle(); footer.Click_on_google(driver);//from w w w . j av a 2 s . com Set<String> windows = driver.getWindowHandles(); Iterator iterator = windows.iterator(); String currentWindowId; while (iterator.hasNext()) { currentWindowId = iterator.next().toString(); if (!currentWindowId.equals(homePage)) { driver.switchTo().window(currentWindowId); } } String actualTitle = driver.getTitle(); System.out.println(actualTitle); String expectedTitle = "IWD Agency - Google+"; assertEquals(expectedTitle, actualTitle); System.out.println("Title is correct"); String currentURL = driver.getCurrentUrl(); System.out.println(currentURL); String expectedcurrentURL = "https://plus.google.com/+Interiorwebdesign"; assertEquals(currentURL, expectedcurrentURL); System.out.println("Link is correct https://plus.google.com/+Interiorwebdesign"); driver.close(); driver.switchTo().window(homePage); }
From source file:net.atf4j.webdriver.WebDriverSmokeTest.java
License:Open Source License
/** * Smoke Test ChromeDriver with Tomcat./*from www. jav a2 s . c om*/ */ @Test public void testChromeTomcat() { // TestContext.assumeLocal(); final WebDriver webDriver = new ChromeDriver(); verifyNotNull(webDriver); verifyTomcatPresent(webDriver); webDriver.close(); }
From source file:net.osgiliath.messaging.repository.impl.itests.ITHelloWebUITest.java
License:Apache License
@Test public void testSayHello() throws Exception { final WebDriver driver; driver = new FirefoxDriver(); // Sleep until the elements we want is visible or 5 seconds is over long end = System.currentTimeMillis() + 10000; (new WebDriverWait(driver, 300)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { driver.get("http://localhost:8181/net.osgiliath.hello.ui"); boolean ret = d.getTitle().toLowerCase().startsWith("hello"); if (!ret) { driver.navigate().refresh(); }/*w ww . j a v a2 s .c om*/ return ret; } }); WebElement element; element = driver.findElement(By.id("helloInput")); element.click(); element.sendKeys(CORRECT_NAME); element = driver.findElement(By.id("helloButton")); element.click(); (new WebDriverWait(driver, 20)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { Collection<WebElement> cells = d.findElements(By.xpath("//table//tr//td")); return cells.size() == 1; } }); end = System.currentTimeMillis() + 10000; driver.close(); }
From source file:org.bigtester.ate.model.page.page.Lastpage.java
License:Apache License
/** * Close lastpage.//from ww w. j a v a 2s .com */ public void closeLastpage() { WebDriver webD = super.getMyWd().getWebDriver(); if (null == webD) { throw new IllegalStateException("webdriver is not correctly populated."); } else { // if (this.getMyWd().getMultiWindowsHandler().getWindows().size()>0) { // webD.switchTo().window(this.getMyWd().getMultiWindowsHandler().getWindows().get(0).getWindowHandle()); webD.close(); // } } }
From source file:org.core.Benchmark.java
License:Open Source License
public void run() { final WebDriver driver = getWebDriver(test); start = new Date(System.currentTimeMillis()); if (test.getWarmup()) for (int i = 0; i < 3; i++) { driver.get(test.getUrl());// w ww.java 2 s. c o m sleep(test.getSleepInterval()); } for (int i = 0; i < test.getIterations(); i++) { long t0 = System.nanoTime(); driver.get(test.getUrl()); browserSummary.addValue((System.nanoTime() - t0) / 1000000L); sleep(test.getSleepInterval()); } driver.close(); }
From source file:org.craftercms.cstudio.share.selenium.basic.CStudioSeleniumUtil.java
License:Open Source License
public static void exit(WebDriver driver) { driver.close(); driver.quit(); }
From source file:org.ehoffman.testing.sample.SimpleTest.java
License:Apache License
@Test public void simpleWebDriverTest() throws InterruptedException, URISyntaxException { /*/*from w ww . j a v a 2 s . c om*/ * this data, a.k.a. the URL is coupled to this test method, due to being co-located with it. Maybe other tests need it as * well, another reason for a global context. */ String url = Thread.currentThread().getContextClassLoader().getResource("index.html").toURI().toString(); /* * Better we have a parameterized factory and ChromeDriver is not imported, * but the factory details are still visible as an import, so still coupled. */ Driver driverType = Driver.CHROME; String name = System.getProperty("BROWSER"); if (name != null) { driverType = Driver.valueOf(System.getProperty("BROWSER")); } final WebDriver driver = new WebDriverFactory().buildWebdriver(driverType, url); assertThat(new SimplePage(driver).setInput(PART1, PART2).getOutput()).isEqualTo(PART1 + " " + PART2); /* * Notice that without control flow any exception may "leak" and entire browser -- try catch, much like @Before/@After are * not really your friend here. */ driver.close(); }
From source file:org.hepaces.surveyfeedbacktestscript.KrogerFeedbackManager.java
public static void main(String[] args) { //test inputs DateTime date = new DateTime(); WebDriver browser = new FirefoxDriver(); String entryId = "014-695-15-858-88-0a"; browser.get("https://www.krogerfeedback.com/"); fillInDateAndTime(date, browser);//w ww .java 2s . c o m fillInEntryId(entryId, browser); clickSubmit(browser); System.out.println(getErrorMessage(browser)); browser.close(); browser.quit(); }