List of usage examples for org.openqa.selenium WebDriver getTitle
String getTitle();
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 av a2 s . c o 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 ww w. j a v a2s . 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 - 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:IWDmainsiteProject.PageObjects.Verify_Pages.java
public static void Verify_reviews(WebDriver driver) { String homePage = driver.getWindowHandle(); footer.Click_on_reviews(driver);//from w ww .j a va2s.c o 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 = "Customer Reviews"; assertEquals(expectedTitle, actualTitle); System.out.println("Title is correct"); String currentURL = driver.getCurrentUrl(); System.out.println(currentURL); String expectedcurrentURL = "https://www.iwdagency.com/reviews/"; assertEquals(currentURL, expectedcurrentURL); System.out.println("Link is correct https://www.iwdagency.com/reviews/"); driver.findElement(By.xpath("//p[contains(.,'IWD Agency Customer Reviews:')]")); driver.findElement(By.xpath("//span[contains(.,'Nothing but amazing!')]")); driver.findElement(By.xpath("//span[contains(.,'Stephanie Moody')]")); //Leave a review driver.findElement( By.cssSelector(".vc_general.vc_btn3.vc_btn3-size-lg.vc_btn3-shape-square.vc_btn3-style-custom")) .click(); String actual_leave_a_review = driver.findElement(By.cssSelector(".rwp-ratings-form-label")).getText(); System.out.println(actual_leave_a_review); String expected_leave_a_reviewe = "LEAVE A REVIEW"; assertEquals(expected_leave_a_reviewe, actual_leave_a_review); System.out.println("Leave a Review title is correct"); driver.findElement( By.cssSelector("div[class=\"rwp-rating-form-content rwp-no-avatar\"] input[placeholder=\"Name\"]")) .sendKeys("IWD Test Name"); driver.findElement(By.cssSelector( "div[class=\"rwp-rating-form-content rwp-no-avatar\"] input[placeholder=\"Review Title\"]")) .sendKeys("IWD Test Review Title"); driver.findElement(By.cssSelector( "div[class=\"rwp-rating-form-content rwp-no-avatar\"] textarea[placeholder=\"Write your review\"]")) .sendKeys("IWD Test Write your review"); String actual_rating = driver.findElement(By.cssSelector(".rwp-lab")).getText(); System.out.println(actual_rating); String expected_rating = "Rating:"; assertEquals(expected_rating, actual_rating); System.out.println("Rating: is correct"); driver.findElement(By.cssSelector( "div[class=\"rwp-stars\"] label[for=\"rwp-rating-1961-4b35bc789a120e0b49c7fcfba6d71488-9-141470591\"]")) .click(); //Make click for submit driver.findElement(By.cssSelector(".rwp-submit-wrap>input")); }
From source file:JavaClasses.DBConnectionIT.java
@Test public void testSimple() throws Exception { // Create a new instance of the Firefox driver // Notice that the remainder of the code relies on the interface, // not the implementation. //WebDriver driver = new FirefoxDriver(); WebDriver driver = new HtmlUnitDriver(); driver.get("http://54.255.142.60:8080/PhoenixConsulting-1.0-SNAPSHOT/index.jsp"); // Check the title of the page // Wait for the page to load, timeout after 10 seconds //(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() { // @Override //public Boolean apply(WebDriver d) { // return d.getTitle().contains("NetBeans"); //}/* w w w. j a v a 2 s. co m*/ String actualTitle = driver.getTitle(); assertTrue(actualTitle.equalsIgnoreCase("Home Page - Phoenix")); WebElement element = driver.findElement(By.name("submit")); element.click(); actualTitle = driver.getTitle(); assertTrue(actualTitle.equalsIgnoreCase("Phoenix Consulting - Details")); element = driver.findElement(By.name("back")); element.click(); actualTitle = driver.getTitle(); assertTrue(actualTitle.equalsIgnoreCase("Home Page - Phoenix")); //Close the browser driver.quit(); }
From source file:jp.vmi.selenium.selenese.subcommand.GetAllWindowTitles.java
License:Apache License
@Override public String[] execute(Context context, String... args) { WebDriver driver = context.getWrappedDriver(); String current = driver.getWindowHandle(); try {/*from ww w . j av a2 s .co m*/ return driver.getWindowHandles().stream().map(handle -> { driver.switchTo().window(handle); return driver.getTitle(); }).toArray(String[]::new); } finally { driver.switchTo().window(current); } }
From source file:limmen.hw4.view.GoogleSearchTest.java
public static void main(String... args) { WebDriver driver = new FirefoxDriver(); driver.navigate().to("http://google.com"); String appTitle = driver.getTitle(); System.out.println("Application title is :: " + appTitle); driver.quit();//from w w w . j ava 2s. co m }
From source file:net.atf4j.webdriver.BrowserFactoryTest.java
License:Open Source License
/** * Verify that verify page loaded./* www .ja va 2 s.c o m*/ * * @param webDriver the web driver */ private void verifyPageLoaded(final WebDriver webDriver) { webDriver.get(TEST_URL); final String currentUrl = webDriver.getCurrentUrl(); this.log.info(currentUrl); final String pageTitle = webDriver.getTitle(); this.log.info(pageTitle); }
From source file:net.atf4j.webdriver.WebDriverSmokeTest.java
License:Open Source License
private void verifyTomcatPresent(final WebDriver webDriver) { TestContext.assumeLocalServer();/*from w w w .java2s . c om*/ webDriver.get("http://127.0.0.1:8080/"); final String pageTitle = webDriver.getTitle(); verifyNotNull(pageTitle); assertTrue(pageTitle.contains("Apache Tomcat")); this.log.info("pageTitle = {}", pageTitle); }
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(); }/*from w w w .j a va2 s.c o m*/ 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:omelet.driver.DriverUtility.java
License:Apache License
/*** * Switching between windows.//from w ww . ja v a 2 s . c om * * @param driver * @param sString * :Target window Title * @return:True if window switched */ public static boolean switchToWindow(WebDriver driver, String sString) { String currentHandle = driver.getWindowHandle(); Set<String> handles = driver.getWindowHandles(); if (!handles.isEmpty()) { for (String handle : handles) { LOGGER.debug("Switching to other window"); driver.switchTo().window(handle); if (sString.equals(driver.getTitle())) { LOGGER.info("switched to window with title:" + sString); return true; } } driver.switchTo().window(currentHandle); LOGGER.info("Window with title:" + sString + " Not present,Not able to switch"); return false; } else { LOGGER.info("There is only one window handle :" + currentHandle); return false; } }