List of usage examples for org.openqa.selenium WebDriver getTitle
String getTitle();
From source file:se.nackademin.seleniumide.assignment.TestProductCategoriesMenu.java
public void navigateMenuProductCategories(WebElement element, String identifier, WebDriver driver, String assertionTitle) {/*from w w w . j av a 2s . c o m*/ Actions builder = new Actions(driver); element = driver.findElement(By.cssSelector("#menu-item-33")); builder.moveToElement(element).perform(); driver.findElement(By.cssSelector(identifier)).click(); Assert.assertEquals(assertionTitle, driver.getTitle()); }
From source file:selenium.EventsPageIT.java
@Test public void testSimple() throws Exception { WebDriver driver = new InternetExplorerDriver(); driver.get("http://localhost:8080/eventlist/events.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// ww w. j a v a2s . co m public Boolean apply(WebDriver d) { return d.getTitle().contains("Events"); } }); //Close the browser driver.quit(); }
From source file:selenium.UploadPageIT.java
@Test public void testSimple() throws Exception { WebDriver driver = new InternetExplorerDriver(); driver.get("http://localhost:8080/eventlist/upload.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/*from w ww .j av a2s . c o m*/ public Boolean apply(WebDriver d) { return d.getTitle().contains("Upload JSON Data"); } }); //Close the browser driver.quit(); }
From source file:selenium_webdriver_test_01.Selenium_Webdriver_Test_01.java
public static void main(String[] args) { // Creates a new instance of the Firefox driver WebDriver driver = new FirefoxDriver(); // WebDriver.get - Opens a URL in Firefox driver.get("http://www.google.com"); // Alternatively the same thing can be done like this: // driver.navigate().to("http://www.google.com"); // WebDriver.findElement(By.name("name")) - Accesses the text input element by its name. WebElement element = driver.findElement(By.name("q")); // .sendKeys("text") - Sends text to text input element. element.sendKeys("Thurse"); // .submit() - Submits the form. Form is found automatically from element. element.submit();/* ww w .j av a 2 s . c om*/ // System.out.println("text" + some.object()) - Prints something on the NetBeans output window // WebDriver.getTitle() - Gets the title of a web page. System.out.println("Page title is: " + driver.getTitle()); // Google's search is rendered dynamically with JavaScript. // Wait for the page to load, timeout after 10 seconds (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.getTitle().toLowerCase().startsWith("thurse"); } }); // Should see: "cheese! - Google Search" System.out.println("Page title is: " + driver.getTitle()); //Close the browser driver.quit(); }
From source file:sf.wicklet.test.support.SeleniumTestUtil.java
License:Apache License
public static void checkTitle(final WebDriver driver, final String expected) { assertEquals(expected, driver.getTitle()); }
From source file:sf.wicklet.test.support.SeleniumTestUtil.java
License:Apache License
public static void checkTitle(final boolean debug, final WebDriver driver, final String expected) { final String title = driver.getTitle(); if (debug) {/*from www. ja va 2 s. co m*/ System.out.println("DEBUB: Page title is: " + title); } assertEquals(expected, title); }
From source file:testrunner.executor.URLStepExecutor.java
License:Apache License
/** * This method executes the step by loading the step's URL using the passed * driver./*from www.ja va 2s . c om*/ */ protected void doExecuteStep(Step step, WebDriver driver, StepResult result) throws Exception { driver.get(step.getUrl()); try { if (driver.getTitle().matches("Certificate Error: Navigation Blocked")) { driver.get("javascript:document.getElementById('overridelink').click();"); Thread.sleep(500); Alert alert = driver.switchTo().alert(); alert.accept(); } } catch (NoAlertPresentException e) { } }
From source file:UITest.Selenium2ExampleIT.java
public void testCodesCrud(DesiredCapabilities browser) { WebDriver driver = null; try {/*from w w w . j ava 2s .co m*/ System.out.println("browser " + browser.toString()); System.out.println("connect to server @ " + SELENIUM_HUB_URL); driver = new RemoteWebDriver(new URL(SELENIUM_HUB_URL), browser); System.out.println("Driver " + driver.toString()); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); System.out.println("Is JSP enabled? " + browser.isJavascriptEnabled()); System.out.println("UI Testing being @ " + TARGET_SERVER_URL); driver.get(TARGET_SERVER_URL); System.out.println("checking for data [" + driver.getTitle() + "]"); assertEquals("Electronics, Cars, Fashion, Collectibles, Coupons and More |eBay", driver.getTitle()); } catch (MalformedURLException e) { e.printStackTrace(); assertTrue(false); } catch (Exception ex) { ex.printStackTrace(); assertTrue(false); } finally { if (driver != null) { // driver.quit(); } else { assertTrue(true); } } }
From source file:uk.co.rockhoppersuk.seleniumtest.dashboard.DashboardAuthenticationPage.java
public DashboardAuthenticationPage(final WebDriver driver, final String portal) { this.driver = driver; this.portal = portal; if (!PAGE_TITLE.equalsIgnoreCase(driver.getTitle())) { driver.get(portal);/*from w ww.j ava 2s . c o m*/ assert PAGE_TITLE.equalsIgnoreCase(driver.getTitle()); } PageFactory.initElements(driver, this); }
From source file:uk.co.rockhoppersuk.seleniumtest.Selenium2Example.java
private void searchGoogle(final WebDriver driver, final String searchText) { driver.get("http://www.google.com"); WebElement element = driver.findElement(By.name("q")); element.sendKeys(searchText);/* w ww. ja v a 2s.com*/ element.submit(); System.out.println("Page Title is : " + driver.getTitle()); (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver d) { return d.getTitle().toLowerCase().startsWith(searchText.toLowerCase()); } }); System.out.println("Page Title is : " + driver.getTitle()); driver.quit(); }