List of usage examples for org.openqa.selenium.support.ui ExpectedConditions presenceOfElementLocated
public static ExpectedCondition<WebElement> presenceOfElementLocated(final By locator)
From source file:com.solidmaps.test.po.LicenseExercitoListPO.java
License:Open Source License
public LicenseExercitoInsertPO update(String idLicense) { driver.findElement(By.id("line_" + idLicense)).click(); (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.id("idLicense"))); return new LicenseExercitoInsertPO(driver); }
From source file:com.solidmaps.test.po.LicenseFederalListPO.java
License:Open Source License
public LicenseFederalListPO delete(String idLicense) { driver.findElement(By.id("check_" + idLicense)).click(); driver.findElement(By.id("btnExcluir")).click(); driver.switchTo().alert().accept();//from www . j av a2s . com (new WebDriverWait(driver, 10)) .until(ExpectedConditions.presenceOfElementLocated(By.id("form-list-license"))); return this; }
From source file:com.solidmaps.test.po.LicenseFederalListPO.java
License:Open Source License
public LicenseFederalInsertPO update(String idLicense) { driver.findElement(By.id("line_" + idLicense)).click(); (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.id("idLicense"))); return new LicenseFederalInsertPO(driver); }
From source file:com.twiceagain.mywebdriver.generators.implementations.Yopmail.java
License:Open Source License
/** * Initialize with the provided username. * * @param user//from w w w . j av a 2 s.c o m */ @Override public void init(String user) { wd.get("http://www.yopmail.com?" + user); // Wait for message frame to appear, and switch to it try { (new WebDriverWait(wd, maxWaitSeconds)) .until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(ifInbox)); } catch (Exception ex) { LOG.warning(ex.getLocalizedMessage()); } // wd now points to the inbox frame. // Wait for at least 1 message to appear try { (new WebDriverWait(wd, maxWaitSeconds)) .until(ExpectedConditions.presenceOfElementLocated(By.xpath(xpDocuments))); } catch (Exception ex) { LOG.warning(ex.getLocalizedMessage()); } super.preloadElements(); }
From source file:com.twiceagain.mywebdriver.generators.WebPageBasic.java
License:Open Source License
/** * Preload elements from current page, or any other initialisation required * for each new page.//from ww w .ja v a2 s. c om * * @return - this page. */ protected WebPageBasic preloadElements() { limiter.incPage(); //System.out.printf("\nDEBUG : preloading elements, page = \n"); // wait for pageLoaded criteria if (xpPageLoadedMarker != null) { try { (new WebDriverWait(wd, maxWaitSeconds)) .until(ExpectedConditions.presenceOfElementLocated(By.xpath(xpPageLoadedMarker))); } catch (Exception ex) { LOG.info(ex.getLocalizedMessage()); // ignore .. } } // We try to load documents loadedElements = null; try { loadedElements = wd.findElements(By.xpath(xpDocuments)); } catch (Exception ex) { loadedElements = null; LOG.info(ex.getLocalizedMessage()); } return this; }
From source file:com.vaadin.addon.spreadsheet.elements.SpreadsheetElement.java
License:Open Source License
private void findSelectionOutline() { // sometimes the spreadsheet takes so long to load that the selection // widget elements are not found new WebDriverWait(getDriver(), 10) .until(ExpectedConditions.presenceOfElementLocated(By.className("s-top"))); sTop = findElement(By.className("s-top")); sBottom = findElement(By.className("s-bottom")); // Just to make sure the left element is present findElement(By.className("s-left")); sRight = findElement(By.className("s-right")); }
From source file:com.vaadin.demo.testutil.AbstractDemoTest.java
License:Apache License
protected void waitForElementPresent(final By by) { waitUntil(ExpectedConditions.presenceOfElementLocated(by)); }
From source file:com.vmware.veei.qe.devcenter.SampleExchangeTest.java
/** * S87854: [Sample Exchange] Search and browse for code samples *//*from w ww. jav a 2s . c om*/ @Test(groups = { "test", "stage" }) @NavigateTo(SAMPLE_CODE_URL) public void testSampleCodeSearchBrowse() { String titleText = "stest"; // #action 1: Adding sample addSample(titleText); // #action 2: Navigate to default page. driver.get(baseUrl + SAMPLE_CODE_URL); selectTab("Samples"); int defaultSampleCodeCount = driver.findElements(By.cssSelector("#search-results-list .title-list li")) .size(); // #action 3: Filter search input check WebElement filterSearchRadioButton = driver.findElement(By.cssSelector("input[value='Python']")); filterSearchRadioButton.click(); int filterSearchCount = driver.findElements(By.cssSelector("#search-results-list .title-list li")).size(); // #expects: Search result should be less then by default result for Filter Search assertThat(defaultSampleCodeCount).isGreaterThanOrEqualTo(filterSearchCount); // #action 4: Navigate to default page. selectTab("Samples"); WebElement globalSearchInputField = driver .findElement(By.cssSelector("#main-content .internal-global-search .search input[type='text']")); // #action 5: Giving text input for search text global search text input globalSearchInputField.sendKeys(titleText); globalSearchInputField.submit(); int sampleCodeSearchCount = driver.findElements(By.cssSelector("#search-results-list .title-list li")) .size(); // #expects: Search result should be less then by default result for Global Search if (defaultSampleCodeCount > 0) { assertThat(defaultSampleCodeCount).isGreaterThanOrEqualTo(sampleCodeSearchCount); } // #action 6: Select Tab : My sample selectTab("My Samples"); // #action 7 : Selecting latest first Select dropdown = new Select(driver.findElement(By.cssSelector("#search-results-sort-by"))); dropdown.selectByIndex(2); List<WebElement> sampleCodeLinkList = driver .findElements(By.cssSelector("#search-results-list .title-list li")); if (sampleCodeSearchCount >= 1) { for (WebElement samplecodelink : sampleCodeLinkList) { String linkHeadText = samplecodelink.findElement(By.cssSelector(".title")).getText(); if (linkHeadText.equals(titleText)) { samplecodelink.click(); samplecodelink.findElement(By.cssSelector("div a")).click(); String sampleCodePageHeadText = driver.findElement(By.cssSelector(".header .span9 h1 ")) .getText(); // #expects: Validating browsed link header with headText assertThat(linkHeadText).isEqualTo(sampleCodePageHeadText); // #expects: Checking Faveroite link WebElement favoriteLink = driver.findElement(By.cssSelector(".favoriteHeart")); String favoriteCount = favoriteLink.getText(); favoriteLink.click(); assertThat(driver.findElement(By.cssSelector(".favoriteHeart"))).isNotEqualTo(favoriteCount); // #action 8: Deleting created JavascriptExecutor jse = (JavascriptExecutor) driver; jse.executeScript("$('.sample-delete-dialog').submit();"); new WebDriverWait(driver, 10).until( ExpectedConditions.presenceOfElementLocated(By.cssSelector("#search-results-list"))); break; } } } }
From source file:com.vmware.veei.qe.devcenter.SampleExchangeTest.java
/** * @param searchText//from w w w. ja v a 2s .c o m * */ private void addSample(String titleText) { // #action 1: Clicking on Add New sample button driver.findElement(By.cssSelector(".admin-actions a")).click(); JavascriptExecutor jse = (JavascriptExecutor) driver; WebElement radioButtonList = new WebDriverWait(driver, 10) .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("input[value='SNIPPET']"))); radioButtonList.click(); jse.executeScript("$('textarea[name=sample-snippet-content]').val('This is a Sample Snippet');"); jse.executeScript("$('input[name=sampleTitle]').val('" + titleText + "');"); // Giving input to Ckeditor // Waiting for 10 second to load ckeditor WebElement ckeditor = new WebDriverWait(driver, 10) .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(".cke_wysiwyg_div"))); ckeditor.click(); ckeditor.sendKeys("Test Description"); // Selecting language Option Select dropdown = new Select(driver.findElement(By.name("sample-language"))); dropdown.selectByIndex(1); // Selecting License Option Select sampleLicenseDropdown = new Select(driver.findElement(By.name("sample-license"))); sampleLicenseDropdown.selectByIndex(1); // Checking multiple inputBoxes driver.findElement(By.cssSelector(".add-platform-input")).click(); List<WebElement> platformInputs = driver.findElements(By.name("sdk-tools")); List<WebElement> platformVersions = driver.findElements(By.name("sdk-tools-versions")); // #expects: Checking multiple checkboxes should have greater then one input for version nnd sdk-tool inputBox assertThat(platformInputs.size()).isGreaterThan(1); assertThat(platformVersions.size()).isGreaterThan(1); // Adding version WebElement version = driver.findElement(By.name("sdk-tools-versions")); version.sendKeys("1.0"); // Add Value to Hidden Field required to Create Sample jse.executeScript("$('[name=sdk-tools]').val('Airwatch').trigger('change');"); jse.executeScript("$('input[name=tags]').val('testing').trigger('change');"); // Agreement check driver.findElement(By.cssSelector("input[type='checkbox']")).click(); // #action 2: submitting the sample WebElement uploadButtonElement = driver.findElement(By.cssSelector("input[type=submit]")); uploadButtonElement.click(); }
From source file:com.vmware.veei.qe.devcenter.SampleExchangeTest.java
/** * S87854: [Sample Exchange] Search and browse for Sample Requests *//* ww w.j ava2 s . co m*/ @Test(groups = { "test", "stage" }) @NavigateTo(SAMPLE_CODE_URL) public void testSampleRequestSearchBrowse() { // #action 1: Selecting request tab selectTab("Requests"); // #action 2: Adding request String titleText = "Rtest"; String language = "java"; String sdkTool = "Airwatch"; addRequest(titleText, language, sdkTool); // #action 3: Navigating to the default page after adding request driver.get(baseUrl + SAMPLE_CODE_URL); selectTab("Requests"); // Total count of sample code presented int defaultRequestCount = driver.findElements(By.cssSelector("#search-results-list .title-list li")).size(); // Filter search input check WebElement filterSearchRadioButton = driver.findElement(By.cssSelector("input[value='Python']")); filterSearchRadioButton.click(); int filterSearchCount = driver.findElements(By.cssSelector("#search-results-list .title-list li")).size(); // #expects: Search result should be less then by default result for Filter Search assertThat(defaultRequestCount).isGreaterThanOrEqualTo(filterSearchCount); // #action 4: Navigating to the default page selectTab("Requests"); WebElement globalSearchInputField = driver .findElement(By.cssSelector("#main-content .internal-global-search .search input[type='text']")); // #action 5: Giving text input for search text global search text input globalSearchInputField.sendKeys(titleText); globalSearchInputField.submit(); // #action 6: Count the total search result int requestSearchCount = driver.findElements(By.cssSelector("#search-results-list .title-list li")).size(); // #expects: Search result should be less then by default result for Global Search if (defaultRequestCount > 0) { assertThat(defaultRequestCount).isGreaterThanOrEqualTo(requestSearchCount); } // #action 7: Select Tab : My request selectTab("My Requests"); // #action 8 : Selecting latest first Select dropdown = new Select(driver.findElement(By.cssSelector("#search-results-sort-by"))); dropdown.selectByIndex(2); List<WebElement> requestLinkList = driver .findElements(By.cssSelector("#search-results-list .title-list li")); if (requestSearchCount >= 1) { for (WebElement requestlink : requestLinkList) { String linkHeadText = requestlink.findElement(By.cssSelector("div a")).getText(); if (linkHeadText.equals(titleText)) { requestlink.click(); requestlink.findElement(By.cssSelector("div a")).click(); String requestlinkPageHeadText = driver.findElement(By.cssSelector(".header-title h1 ")) .getText(); // #expects: Validating browsed link header assertThat(linkHeadText).isEqualTo(requestlinkPageHeadText); // #action 9: Deleting created JavascriptExecutor jse = (JavascriptExecutor) driver; jse.executeScript("$('.request-delete-dialog').submit();"); new WebDriverWait(driver, 10).until( ExpectedConditions.presenceOfElementLocated(By.cssSelector("#search-results-list"))); break; } } } }