List of usage examples for org.openqa.selenium.support.ui ExpectedConditions visibilityOfElementLocated
public static ExpectedCondition<WebElement> visibilityOfElementLocated(final By locator)
From source file:org.alfresco.po.common.util.Utils.java
License:Open Source License
/** * Helper method to wait for the visibility of element located * by selector// w ww . j a va2s. co m */ public static void waitForVisibilityOf(By locator) { webDriverWait().until(ExpectedConditions.visibilityOfElementLocated(locator)); }
From source file:org.alfresco.po.PageElement.java
License:Open Source License
/** * Wait until the element is visible for the specified amount of time. * @param locator CSS Locator//w w w . j ava 2 s . co m * @param timeOutInSeconds Timeout In Seconds */ public void waitForElement(By locator, long timeOutInSeconds) { if (locator == null) { throw new IllegalArgumentException(LOCATOR_REQUIRED_ERR_MSG); } WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds); wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); }
From source file:org.alfresco.po.RenderElement.java
License:Open Source License
/** * Wait until the element is visible for the specified amount of time. * @param driver WebDriver// w w w.ja v a2 s .com * @param locator CSS Locator * @param timeOutInSeconds Timeout In Seconds */ public void waitForElement(WebDriver driver, By locator, long timeOutInSeconds) { if (locator == null) { throw new IllegalArgumentException(LOCATOR_REQUIRED_ERR_MSG); } WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds); wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); }
From source file:org.alfresco.po.share.page.Message.java
License:Open Source License
/** * Wait for message to be hidden/*from www . jav a2s. co m*/ */ public void waitUntillHidden() { boolean shown = false; try { webDriverWait(1).until(ExpectedConditions.visibilityOfElementLocated(MESSAGE_SELECTOR)); shown = true; } catch (TimeoutException exception) { // do nothing and carry on } if (shown == true) { try { webDriverWait().until(ExpectedConditions.invisibilityOfElementLocated(MESSAGE_SELECTOR)); } catch (TimeoutException exception) { // do nothing and carry on } } }
From source file:org.alfresco.po.share.page.Message.java
License:Open Source License
/** * Wait for the message to appear/* w w w. j a v a 2 s . c om*/ */ public void waitUntillVisible() { try { webDriverWait().until(ExpectedConditions.visibilityOfElementLocated(MESSAGE_SELECTOR)); } catch (TimeoutException exception) { // do nothing and carry on } }
From source file:org.apache.archiva.web.test.ArchivaAdminTest.java
License:Apache License
@Test public void testInitialRepositories() { WebDriverWait wait = new WebDriverWait(getWebDriver(), 20); WebElement el;// ww w. ja v a 2 s.c o m el = wait.until(ExpectedConditions.elementToBeClickable(By.id("menu-repositories-list-a"))); tryClick(el, ExpectedConditions.presenceOfElementLocated( By.xpath("//table[@id='managed-repositories-table']//td[contains(text(),'internal')]")), "Managed Repositories not activated"); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//table[@id='managed-repositories-table']//td[contains(text(),'snapshots')]"))); el = wait.until( ExpectedConditions.elementToBeClickable(By.xpath("//a[@href='#remote-repositories-content']"))); tryClick(el, ExpectedConditions.visibilityOfElementLocated( By.xpath("//table[@id='remote-repositories-table']//td[contains(text(),'central')]")), "Remote Repositories View not available"); }
From source file:org.apache.archiva.web.test.parent.AbstractArchivaTest.java
License:Apache License
private void createUser(String userName, String fullName, String emailAd, String password, String confirmPassword, boolean valid) { login(getAdminUsername(), getAdminPassword()); WebDriverWait wait = new WebDriverWait(getWebDriver(), 10); WebElement el = wait.until(ExpectedConditions.elementToBeClickable(By.id("menu-users-list-a"))); el = tryClick(el, ExpectedConditions.elementToBeClickable(By.id("users-view-tabs-li-user-edit-a")), "User List not available"); el = tryClick(el, ExpectedConditions.elementToBeClickable(By.id("users-view-tabs-li-user-edit-a")), "User Edit View not available"); el = tryClick(el, ExpectedConditions.elementToBeClickable(By.id("user-create-form-register-button")), "Register Form not available"); assertCreateUserPage();//from w w w .ja va 2 s . c o m setFieldValue("username", userName); setFieldValue("fullname", fullName); setFieldValue("email", emailAd); setFieldValue("password", password); setFieldValue("confirmPassword", confirmPassword); el.click(); if (valid) { wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("user-messages"), "User " + userName + " created.")); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("users-grid-user-id-" + userName))); //String[] columnValues = { userName, fullName, emailAd }; //assertElementPresent( XPathExpressionUtil.getTableRow( columnValues ) ); } else { assertCreateUserPage(); } }
From source file:org.apache.archiva.web.test.parent.AbstractArchivaTest.java
License:Apache License
protected void logout() { clickLinkWithLocator("logout-link-a"); WebDriverWait wait = new WebDriverWait(getWebDriver(), 10); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[text()='Login']//ancestor::a"))); assertTextNotPresent("Current User:"); assertLinkNotVisible("Edit Details"); assertLinkNotVisible("Logout"); assertLinkVisible("Login"); }
From source file:org.apache.archiva.web.test.parent.AbstractSeleniumTest.java
License:Apache License
public void initializeArchiva(String baseUrl, String browser, int maxWaitTimeInMs, String seleniumHost, int seleniumPort, boolean remoteSelenium) throws Exception { open(baseUrl, browser, seleniumHost, seleniumPort, maxWaitTimeInMs, remoteSelenium); loadPage(baseUrl, 30);//from w w w .j a va 2 s . com WebDriverWait wait = new WebDriverWait(getWebDriver(), 30); wait.until(ExpectedConditions.presenceOfElementLocated(By.id("topbar-menu"))); wait = new WebDriverWait(getWebDriver(), 20); Boolean found = wait.until( ExpectedConditions.or(ExpectedConditions.visibilityOfElementLocated(By.id("create-admin-link-a")), ExpectedConditions.visibilityOfElementLocated(By.id("login-link-a")))); if (found) { WebElement adminLink = getWebDriver().findElement(By.id("create-admin-link-a")); WebElement loginLink = getWebDriver().findElement(By.id("login-link-a")); // if not admin user created create one if (adminLink != null && adminLink.isDisplayed()) { Assert.assertFalse(isElementVisible("login-link-a")); Assert.assertFalse(isElementVisible("register-link-a")); // skygo need to set to true for passing is that work as expected ? adminLink.click(); wait = new WebDriverWait(getWebDriver(), 10); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("user-create"))); assertCreateAdmin(); String fullname = getProperty("ADMIN_FULLNAME"); String username = getAdminUsername(); String mail = getProperty("ADMIN_EMAIL"); String password = getProperty("ADMIN_PASSWORD"); submitAdminData(fullname, mail, password); assertUserLoggedIn(username); clickLinkWithLocator("logout-link-a", false); } else if (loginLink != null && loginLink.isDisplayed()) { Assert.assertTrue(isElementVisible("login-link-a")); Assert.assertTrue(isElementVisible("register-link-a")); login(getAdminUsername(), getAdminPassword()); } } }
From source file:org.apache.archiva.web.test.parent.AbstractSeleniumTest.java
License:Apache License
public void goToLoginPage() { logger.info("Goto login page"); loadPage(baseUrl, 30);/* ww w. j a v a 2s . c om*/ WebDriverWait wait = new WebDriverWait(getWebDriver(), 30); wait.until(ExpectedConditions.presenceOfElementLocated(By.id("topbar-menu"))); wait.until(ExpectedConditions.or(ExpectedConditions.visibilityOfElementLocated(By.id("logout-link")), ExpectedConditions.visibilityOfElementLocated(By.id("login-link-a")))); // are we already logged in ? if (isElementVisible("logout-link")) //isElementPresent( "logoutLink" ) ) { logger.info("Logging out "); // so logout clickLinkWithLocator("logout-link-a", false); } wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("login-link-a"))); clickLinkWithLocator("login-link-a", false); // This is a workaround for bug with HTMLUnit. The display attribute of the // login dialog is not changed via the click. // TODO: Check after changing jquery, bootstrap or htmlunit version if (getWebDriver() instanceof HtmlUnitDriver) { ((JavascriptExecutor) getWebDriver()).executeScript("$('#modal-login').show();"); } // END OF WORKAROUND wait = new WebDriverWait(getWebDriver(), 20); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("modal-login"))); assertLoginModal(); }