List of usage examples for org.openqa.selenium WebDriver getTitle
String getTitle();
From source file:com.tractionsoftware.reshoot.teampage.LoginPage.java
License:Apache License
public LoginPage(WebDriver driver) { this.driver = driver; if (!driver.getTitle().contains("Log In")) { throw new IllegalStateException("This page title does not contain: Log In"); }//from w w w.j a va 2 s . co m }
From source file:com.tractionsoftware.reshoot.teampage.ProteusPage.java
License:Apache License
public ProteusPage(WebDriver driver, String htmlTitlePrefix) { this.driver = driver; if (!isProteusPage(driver)) { throw new IllegalStateException("This page does not appear to be a Proteus page."); }//w w w . j a v a 2 s .c o m waitForProteusIdle(60); // make sure we're on the right page. this avoids if (!driver.getTitle().startsWith(htmlTitlePrefix)) { throw new IllegalStateException("This page title does not start with: " + htmlTitlePrefix); } }
From source file:com.twiceagain.mywebdriver.driver.web.DriversTest.java
License:Open Source License
protected String openPage(WebDriver wd) { wd.get("http://www.google.com"); return wd.getTitle(); }
From source file:com.twiceagain.rservejavademo.webaccess.BasicDriverTest.java
/** * Test of _getDriver method, of class BasicDriver. * @throws java.lang.InterruptedException *///w w w .j a va 2 s . c o m @Test public void testGetDriver() throws InterruptedException { System.out.println("getDriver"); WebDriver expResult = null; WebDriver wd = BasicDriver.getDriver(); wd.get("http://www.google.fr"); Thread.sleep(1000); assert (wd.getTitle().contains("Google")); WebElement searchBox = wd.findElement(By.name("q")); searchBox.sendKeys("ChromeDriver test"); searchBox.submit(); Thread.sleep(5000); // Let the user actually see something! wd.close(); }
From source file:com.vaadin.testbench.TestBenchDriverTest.java
@Test public void testTestBenchDriverActsAsProxy() { FirefoxDriver mockDriver = createMock(FirefoxDriver.class); mockDriver.close();// ww w . j av a 2 s.c om expectLastCall().once(); WebElement mockElement = createNiceMock(WebElement.class); expect(mockDriver.findElement(isA(By.class))).andReturn(mockElement); List<WebElement> elements = Arrays.asList(mockElement); expect(mockDriver.findElements(isA(By.class))).andReturn(elements); mockDriver.get("foo"); expectLastCall().once(); expect(mockDriver.getCurrentUrl()).andReturn("foo"); expect(mockDriver.getPageSource()).andReturn("<html></html>"); expect(mockDriver.getTitle()).andReturn("bar"); expect(mockDriver.getWindowHandle()).andReturn("baz"); Set<String> handles = new HashSet<String>(); expect(mockDriver.getWindowHandles()).andReturn(handles); Options mockOptions = createNiceMock(Options.class); expect(mockDriver.manage()).andReturn(mockOptions); Navigation mockNavigation = createNiceMock(Navigation.class); expect(mockDriver.navigate()).andReturn(mockNavigation); mockDriver.quit(); expectLastCall().once(); expect(((JavascriptExecutor) mockDriver).executeScript(anyObject(String.class))).andStubReturn(true); TargetLocator mockTargetLocator = createNiceMock(TargetLocator.class); expect(mockDriver.switchTo()).andReturn(mockTargetLocator); replay(mockDriver); // TestBenchDriverProxy driver = new TestBenchDriverProxy(mockDriver); WebDriver driver = TestBench.createDriver(mockDriver); driver.close(); By mockBy = createNiceMock(By.class); assertTrue(driver.findElement(mockBy) instanceof TestBenchElementCommands); assertTrue(driver.findElements(mockBy).get(0) instanceof TestBenchElementCommands); driver.get("foo"); assertEquals("foo", driver.getCurrentUrl()); assertEquals("<html></html>", driver.getPageSource()); assertEquals("bar", driver.getTitle()); assertEquals("baz", driver.getWindowHandle()); assertEquals(handles, driver.getWindowHandles()); assertEquals(mockOptions, driver.manage()); assertEquals(mockNavigation, driver.navigate()); driver.quit(); assertEquals(mockTargetLocator, driver.switchTo()); verify(mockDriver); }
From source file:com.volkhart.selenium.util.Window.java
License:Apache License
/** * Switches the WebDriver pointer to the specified window * /*from w ww . ja v a 2s. c om*/ * Uses {@code String.contains()} to identify windows. * * @param driver * WebDriver being redirected * @param partialTitle * A portion of the title of the window. */ public static void switchTo(WebDriver driver, String partialTitle) { Set<String> windows = driver.getWindowHandles(); for (String s : windows) { driver.switchTo().window(s); if (driver.getTitle().toLowerCase().contains(partialTitle.toLowerCase())) break; } }
From source file:de.akquinet.devops.test.ui.view.GitblitDashboardView.java
License:Apache License
synchronized public void waitToLoadFor(int sec) { WebDriverWait webDriverWait = new WebDriverWait(getDriver(), sec); webDriverWait.until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.getTitle().toLowerCase().startsWith(GitblitDashboardView.TITLE_STARTS_WITH); }//from w ww.j a v a 2 s.com }); }
From source file:de.betterform.conformance.WebDriverTestFunctions.java
License:BSD License
public void waitForTitle(final String title) { (new WebDriverWait(webDriver, 30)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return title.equals(d.getTitle()); }/*from w w w .ja v a2s .c o m*/ }); }
From source file:de.betterform.conformance.WebDriverTestFunctions.java
License:BSD License
public void hasException() { (new WebDriverWait(webDriver, 30)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return "Error".equals(d.getTitle()); }/*from w w w . j a v a2s .c om*/ }); }
From source file:de.codecentric.janus.plugin.library.SeleniumAdapter.java
License:Apache License
private void reloadConfiguration() throws Exception { assert driver != null; int timeoutInSeconds = Config.getTimeoutInSeconds(); if (Config.isRestartReloadStrategy()) { driver.get(Config.getJenkinsBaseUrl() + "restart"); driver.findElement(By.cssSelector("form[action=\"restart\"] " + "button")).click(); timeoutInSeconds *= 6;//from w w w . ja v a 2s.c o m } else { driver.get(Config.getJenkinsBaseUrl() + "reload"); } new WebDriverWait(driver, timeoutInSeconds).until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(@Nullable WebDriver driver) { return driver.getTitle().startsWith("Dashboard"); } }); }