List of usage examples for org.openqa.selenium.support.ui ExpectedConditions textToBePresentInElementLocated
public static ExpectedCondition<Boolean> textToBePresentInElementLocated(final By locator, final String text)
From source file:io.github.bonigarcia.wdm.test.RemoteTest.java
License:Apache License
@Test public void test() { WebDriverWait wait = new WebDriverWait(driver, 30); driver.get("https://en.wikipedia.org/wiki/Main_Page"); By searchInput = By.id("searchInput"); wait.until(ExpectedConditions.presenceOfElementLocated(searchInput)); driver.findElement(searchInput).sendKeys("Software"); By searchButton = By.id("searchButton"); wait.until(ExpectedConditions.elementToBeClickable(searchButton)); driver.findElement(searchButton).click(); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.tagName("body"), "Computer software")); }
From source file:org.alfresco.po.PageElement.java
License:Open Source License
public void waitUntilVisible(By locator, String text, long timeOutInSeconds) { if (locator == null) { throw new IllegalArgumentException(LOCATOR_REQUIRED_ERR_MSG); }//from ww w.ja v a 2 s . c om if (text == null || text.isEmpty()) { throw new IllegalArgumentException("Text value is required"); } WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds); wait.until(ExpectedConditions.textToBePresentInElementLocated(locator, text)); }
From source file:org.apache.archiva.web.test.LoginTest.java
License:Apache License
@Test public void testWithBadUsername() { goToLoginPage();/*from w ww .j a v a2s .c o m*/ setFieldValue("user-login-form-username", "badUsername"); clickLinkWithLocator("modal-login-ok", false); WebDriverWait wait = new WebDriverWait(getWebDriver(), 2); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("modal-login"), "This field is required.")); }
From source file:org.apache.archiva.web.test.LoginTest.java
License:Apache License
@Test public void testWithBadPassword() { goToLoginPage();/*from w w w.j a v a 2s . c om*/ setFieldValue("user-login-form-username", getProperty("ADMIN_USERNAME")); setFieldValue("user-login-form-password", "badPassword"); clickLinkWithLocator("modal-login-ok", false); WebDriverWait wait = new WebDriverWait(getWebDriver(), 2); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("modal-login"), "You have entered an incorrect username and/or password")); }
From source file:org.apache.archiva.web.test.LoginTest.java
License:Apache License
@Test public void testWithEmptyUsername() { goToLoginPage();/* w ww.ja va 2 s. co m*/ setFieldValue("user-login-form-password", "password"); clickLinkWithLocator("modal-login-ok", false); WebDriverWait wait = new WebDriverWait(getWebDriver(), 2); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("modal-login"), "This field is required.")); }
From source file:org.apache.archiva.web.test.LoginTest.java
License:Apache License
@Test public void testWithEmptyPassword() { goToLoginPage();/*from w ww .j av a2s . c om*/ setFieldValue("user-login-form-username", getProperty("ADMIN_USERNAME")); Assert.assertTrue(getWebDriver().findElement(By.id("modal-login-ok")).isDisplayed()); Assert.assertTrue(getWebDriver().findElement(By.id("modal-login-ok")).isEnabled()); clickLinkWithLocator("modal-login-ok", false); WebDriverWait wait = new WebDriverWait(getWebDriver(), 2); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("modal-login"), "This field is required.")); }
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 va2s .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.RepositoryAdminTest.java
License:Apache License
@Test public void testManagedRepository() { // login( getAdminUsername(), getAdminPassword() ); WebDriverWait wait = new WebDriverWait(getWebDriver(), 20); WebElement el;//from w ww. ja v a2s . c om el = wait.until(ExpectedConditions.elementToBeClickable(By.id("menu-repositories-list-a"))); tryClick(el, ExpectedConditions.presenceOfElementLocated(By.id("managed-repositories-view-a")), "Managed Repositories not activated"); 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"); el = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@href='#remote-repository-edit']"))); el = tryClick(el, ExpectedConditions.visibilityOfElementLocated(By.id("remote-repository-save-button")), "Repository Save Button not available"); setFieldValue("id", "myrepoid"); setFieldValue("name", "My repo name"); setFieldValue("url", "http://www.repo.org"); el = wait.until(ExpectedConditions.elementToBeClickable(By.id("remote-repository-save-button"))); Actions actions = new Actions(getWebDriver()); actions.moveToElement(el); actions.perform(); ((JavascriptExecutor) getWebDriver()).executeScript("arguments[0].scrollIntoView();", el); el.click(); el = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("remote-repositories-view-a"))); ((JavascriptExecutor) getWebDriver()).executeScript("arguments[0].scrollIntoView();", el); tryClick(By.id("menu-proxy-connectors-list-a"), ExpectedConditions .visibilityOfElementLocated(By.id("proxy-connectors-view-tabs-a-network-proxies-grid")), "Network proxies not available", 3, 10); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("main-content"), "Proxy Connectors")); // proxy connect wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("proxy-connectors-view"), "central")); assertTextNotPresent("myrepoid"); el = wait.until(ExpectedConditions.elementToBeClickable(By.id("proxy-connectors-view-tabs-a-edit"))); el.click(); el = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("proxy-connector-btn-save"))); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("remote-repository-edit-fieldset"))); // Another hack, don't know why the normal selectValue() does not work here ((JavascriptExecutor) getWebDriver()).executeScript("jQuery('#sourceRepoId').css('display','block')"); Select select = new Select(getWebDriver().findElement(By.xpath(".//select[@id='sourceRepoId']"))); select.selectByVisibleText("internal"); // selectValue( "sourceRepoId", "internal", true ); // Workaround // TODO: Check after upgrade of htmlunit, bootstrap or jquery // TODO: Check whats wrong here ((JavascriptExecutor) getWebDriver()).executeScript("$('#targetRepoId').show();"); // End of Workaround wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("targetRepoId"))); selectValue("targetRepoId", "myrepoid"); el.click(); wait.until( ExpectedConditions.textToBePresentInElementLocated(By.id("user-messages"), "ProxyConnector added")); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("proxy-connectors-view"), "central")); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("proxy-connectors-view"), "myrepoid")); tryClick(By.xpath("//i[contains(@class,'icon-resize-vertical')]//ancestor::a"), ExpectedConditions.visibilityOfAllElementsLocatedBy(By.id("proxy-connector-edit-order-div")), "Edit order view not visible", 3, 10); // clickLinkWithXPath( "//i[contains(@class,'icon-resize-vertical')]//ancestor::a"); // This is needed here for HTMLUnit Tests. Currently do not know why, wait is not working for the // list entries down // waitPage(); // el = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("proxy-connector-edit-order-div"))); assertTextPresent("internal"); List<WebElement> repos = wait.until(ExpectedConditions .numberOfElementsToBe(By.xpath("//div[@id='proxy-connector-edit-order-div']/div"), 2)); Assert.assertTrue("First repo is myrepo", repos.get(0).getText().contains("myrepoid")); Assert.assertTrue("Second repo is central", repos.get(1).getText().contains("central")); // works until this point /*getSelenium().mouseDown( "xpath=//div[@id='proxy-connector-edit-order-div']/div[1]" ); getSelenium().mouseMove( "xpath=//div[@id='proxy-connector-edit-order-div']/div[2]" ); getSelenium().mouseUp( "xpath=//div[@id='proxy-connector-edit-order-div']/div[last()]" ); Assert.assertTrue( "Second repo is myrepo", getSelenium().getText("xpath=//div[@id='proxy-connector-edit-order-div']/div[2]" ).contains( "myrepoid" )); Assert.assertTrue( "First repo is central", getSelenium().getText("xpath=//div[@id='proxy-connector-edit-order-div']/div[1]" ).contains( "central" )); */ }
From source file:org.apache.archiva.web.test.RolesManagementTest.java
License:Apache License
@Test public void testReadRolesAndUpdateDescription() throws Exception { login(getAdminUsername(), getAdminPassword()); WebDriverWait wait = new WebDriverWait(getWebDriver(), 10); WebElement link = wait.until(ExpectedConditions.elementToBeClickable(By.id("menu-roles-list-a"))); tryClick(link, ExpectedConditions.textToBePresentInElementLocated(By.id("roles-view"), "Archiva System Administrator"), "Roles view not available"); Assert.assertTrue(StringUtils.isEmpty(getText("role-description-Guest"))); clickLinkWithLocator("edit-role-Guest"); wait.until(ExpectedConditions.elementToBeClickable(By.id("role-edit-description-save"))); String desc = "The guest description"; setFieldValue("role-edit-description", desc); clickButtonWithLocator("role-edit-description-save"); wait.until(// w ww . j ava 2 s . c om ExpectedConditions.textToBePresentInElementLocated(By.id("user-messages"), "Role Guest updated.")); clickLinkWithLocator("roles-view-tabs-a-roles-grid"); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("role-description-Guest"), desc)); }
From source file:org.apache.geode.tools.pulse.tests.ui.PulseTestUtils.java
License:Apache License
public static void verifyTextPresrntById(String id, String text) { WebDriverWait wait = new WebDriverWait(getDriver(), maxWaitTime, 500); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id(id), text)); }