List of usage examples for org.openqa.selenium.support.ui ExpectedConditions titleIs
public static ExpectedCondition<Boolean> titleIs(final String title)
From source file:org.structr.web.frontend.selenium.LoginChromeTest.java
License:Open Source License
@Test public void testSuccessfulLogin() { createAdminUser();/*from w w w .j a v a2 s . co m*/ driver.get("http://localhost:8875/structr/#dashboard"); assertEquals("Username field not found", 1, driver.findElements(By.id("usernameField")).size()); assertEquals("Password field not found", 1, driver.findElements(By.id("passwordField")).size()); assertEquals("Login button not found", 1, driver.findElements(By.id("loginButton")).size()); final WebDriverWait wait = new WebDriverWait(driver, 2); final WebElement usernameField = wait .until(ExpectedConditions.visibilityOfElementLocated(By.id("usernameField"))); usernameField.sendKeys("admin"); final WebElement passwordField = wait .until(ExpectedConditions.visibilityOfElementLocated(By.id("passwordField"))); passwordField.sendKeys("admin"); final WebElement loginButton = wait .until(ExpectedConditions.visibilityOfElementLocated(By.id("loginButton"))); loginButton.click(); wait.until(ExpectedConditions.titleIs("Structr Dashboard")); assertEquals("Structr Dashboard", driver.getTitle()); }
From source file:org.structr.web.frontend.selenium.SeleniumTest.java
License:Open Source License
/** * Login into the backend UI as admin/admin using the given web driver and switch to the given menu entry. * * @param menuEntry//from w ww .j a va 2 s .c om * @param driver * @param waitForSeconds */ protected static void loginAsAdmin(final String menuEntry, final WebDriver driver, final int waitForSeconds) { driver.get("http://localhost:8875/structr/#" + menuEntry.toLowerCase()); final WebDriverWait wait = new WebDriverWait(driver, waitForSeconds); //wait.until((ExpectedCondition<Boolean>) (final WebDriver f) -> (Boolean) ((JavascriptExecutor) f).executeScript("LSWrapper.isLoaded()")); assertEquals("Username field not found", 1, driver.findElements(By.id("usernameField")).size()); assertEquals("Password field not found", 1, driver.findElements(By.id("passwordField")).size()); assertEquals("Login button not found", 1, driver.findElements(By.id("loginButton")).size()); final WebElement usernameField = wait .until(ExpectedConditions.visibilityOfElementLocated(By.id("usernameField"))); final WebElement passwordField = wait .until(ExpectedConditions.visibilityOfElementLocated(By.id("passwordField"))); final WebElement loginButton = wait .until(ExpectedConditions.visibilityOfElementLocated(By.id("loginButton"))); usernameField.sendKeys("admin"); passwordField.sendKeys("admin"); loginButton.click(); try { wait.until(ExpectedConditions.titleIs("Structr " + menuEntry)); } catch (WebDriverException wex) { try { Runtime.getRuntime().exec( "/usr/bin/jstack -l $(ps xa|grep structr|grep java|tail -n1|awk '{print $1}') > /tmp/jstack.out." + new Date().getTime()); } catch (IOException ex1) { throw new RuntimeException(ex1); } } catch (RuntimeException ex) { throw ex; } assertEquals("Structr " + menuEntry, driver.getTitle()); }
From source file:org.wso2.appmanager.ui.integration.test.cases.PublisherMandatoryFieldValidationWebAppTestCase.java
License:Open Source License
@BeforeClass(alwaysRun = true) public void startUp() throws Exception { super.init(); //login to publisher webAppsListPage = (PublisherWebAppsListPage) login(driver, LoginPage.LoginTo.PUBLISHER); new WebDriverWait(driver, 90).until(ExpectedConditions.titleIs("webapp | WSO2 App Manager")); }
From source file:org.wso2.iot.integration.ui.pages.home.IOTAdminDashboard.java
License:Open Source License
public IOTAdminDashboard(WebDriver driver) throws IOException { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); WebDriverWait wait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); if (!wait.until(ExpectedConditions.titleIs(uiElementMapper.getElement("cdmf.home.page")))) { throw new IllegalStateException("This is not the home page"); }/*from www . j av a 2s. c om*/ }
From source file:org.wso2.iot.integration.ui.pages.home.IOTHomePage.java
License:Open Source License
public IOTHomePage(WebDriver driver) throws IOException { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); // Check that we're on the right page. WebDriverWait wait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); if (!wait.until(ExpectedConditions.titleIs(uiElementMapper.getElement("cdmf.user.home.page")))) { throw new IllegalStateException("This is not the home page"); }/*from ww w .j a va2 s . com*/ }
From source file:pawl.jbehave.step.BrowserSteps.java
License:Apache License
/** * Verify the current page title./*from w ww . java2s . c o m*/ * * @param title for check */ @Then("I get title '$title'") public void verifyTitle(final String title) { browser.base().getWait().until(ExpectedConditions.titleIs(Resources.base().string(title, title))); }
From source file:test.nov21.configuration.AbstractPage.java
License:Open Source License
public void pageTitleWait(String title, int timeOut) { Wait<WebDriver> wait = new WebDriverWait(getDriver(), timeOut); wait.until(ExpectedConditions.titleIs(title)); }