List of usage examples for org.openqa.selenium.support.ui ExpectedConditions textToBePresentInElement
public static ExpectedCondition<Boolean> textToBePresentInElement(final WebElement element, final String text)
From source file:com.nowsprinting.hellotesting.appiumtest.appium.page.DetailPage.java
License:Apache License
/** * ????????????/*from w w w . j av a 2 s . co m*/ * * @param numberPicker ??NumberPicker * @param expectedAge */ private void waitUntilAgeToBe(WebElement numberPicker, int expectedAge) throws Exception { WebElement ageTextField = numberPicker.findElement(By.className(WIDGET_EDIT_TEXT)); mWait.until(ExpectedConditions.textToBePresentInElement(ageTextField, String.valueOf(expectedAge))); TimeUnit.SECONDS.sleep(1); }
From source file:com.sugarcrm.candybean.automation.control.Pause.java
License:Open Source License
public VControl untilTextPresent(String text, int timeout_ms) throws Exception { (new WebDriverWait(this.c.iface.wd, timeout_ms)) .until(ExpectedConditions.textToBePresentInElement(this.c.getBy(), text)); return this.c; }
From source file:com.sugarcrm.candybean.automation.webdriver.WebDriverPause.java
License:Open Source License
public WebDriverElement untilTextPresent(String text, int timeout) throws CandybeanException { (new WebDriverWait(this.wde.wd, timeout)) .until(ExpectedConditions.textToBePresentInElement(this.wde.getBy(), text)); return this.wde; }
From source file:com.vha.techdev.webapp.test.SimpleTest.java
License:Apache License
@Test public void testSimple() throws Exception { driver.get(serverUrl + "index.html"); // wait a bit ajax response new WebDriverWait(driver, 2).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver driver) { return driver.findElements(By.className("info").id("version")).size() > 0; }//w ww. j ava 2 s. com }); WebElement version = driver.findElement(By.id("version")); Assert.assertEquals(ComponentInfo.IMPLEMENTATION.toString(), version.getText()); String whoToSend = "foo"; WebElement who = driver.findElement(By.id("who")); who.sendKeys(whoToSend); WebElement sendBtn = driver.findElement(By.id("send-btn")); sendBtn.click(); // wait a bit ajax response new WebDriverWait(driver, 2) .until(ExpectedConditions.textToBePresentInElement(By.id("response"), whoToSend)); WebElement response = driver.findElement(By.id("response")); Assert.assertEquals("Hello " + whoToSend, response.getText()); }
From source file:dk.dma.ais.abnormal.web.StatisticDataIT.java
License:Open Source License
private void clickOnACell() throws InterruptedException { zoomIntoHelsinore();//from w w w. j a v a2 s .com waitForCellsToBeDisplayed(); WebElement map = getMap(); Actions actions = new Actions(browser); actions.moveToElement(map, map.getSize().getWidth() / 2, map.getSize().getHeight() / 2); actions.click(); actions.perform(); // Cursor position is exactly in the center of the map browser.findElement(By.id("tab-map")).click(); assertEquals("(5602'05.7\"N, 1238'59.7\"E)", browser.findElement(By.cssSelector("div#cursorpos.useroutput p")).getText()); // Assert statistic data for correct cell displayed final String expectedCellInfo = "Cell id 6249302540 (5602'06.5\"N,1238'53.8\"E) - (5602'00\"N,1239'00.3\"E)"; By actualCellInfoElement = By.cssSelector("div.cell-data-contents > h5"); wait.until(ExpectedConditions.textToBePresentInElement(actualCellInfoElement, expectedCellInfo)); }
From source file:dk.dma.ais.abnormal.web.StatisticDataIT.java
License:Open Source License
private void zoomIntoHelsinore() throws InterruptedException { if (browser instanceof JavascriptExecutor) { ((JavascriptExecutor) browser).executeScript( "mapModule.map.setCenter(new OpenLayers.LonLat(12.65,56.035).transform(new OpenLayers.Projection(\"EPSG:4326\"), new OpenLayers.Projection(\"EPSG:900913\")), 12)"); }/*from w ww .j ava 2s . co m*/ browser.findElement(By.id("tab-map")).click(); final String expectedViewPortInfo = "(5605'06.8\"N, 1230'02.4\"E)\n(5559'05\"N, 1247'57.6\"E)"; By actualViewPortInfoElement = By.cssSelector("div#viewport.useroutput p"); wait.until(ExpectedConditions.textToBePresentInElement(actualViewPortInfoElement, expectedViewPortInfo)); }
From source file:dk.dma.ais.abnormal.web.StatisticDataIT.java
License:Open Source License
private void checkCellsAreDisplayedWhenZoomingIn() throws InterruptedException { assertCellLayerLoadStatusNoCellsLoaded(); try {/* ww w . j a v a2s .c o m*/ WebElement zoomIn = browser.findElement(By.cssSelector("a.olControlZoomIn.olButton")); zoomIn.click(); Thread.sleep(300); assertCellLayerLoadStatusNoCellsLoaded(); zoomIn.click(); Thread.sleep(300); assertCellLayerLoadStatusNoCellsLoaded(); zoomIn.click(); Thread.sleep(300); assertCellLayerLoadStatusNoCellsLoaded(); zoomIn.click(); Thread.sleep(300); assertCellLayerLoadStatusNoCellsLoaded(); zoomIn.click(); wait.until(ExpectedConditions.textToBePresentInElement(By.id("cell-layer-load-status"), "61 cells loaded, 61 added to map.")); } catch (Throwable e) { if (browser instanceof TakesScreenshot) { IntegrationTestHelper.takeScreenshot(browser, "error"); } throw e; } }
From source file:functional.org.ojbc.web.portal.controllers.TestBase.java
License:RPL License
public static void waitForTextNotPresentFromInput(By by, String text, WebDriver driver) { WebDriverWait webDriverWait = new WebDriverWait(driver, WAIT_IN_SECONDS); try {// ww w. j av a2s . c om webDriverWait.until(ExpectedConditions.not(ExpectedConditions.textToBePresentInElement(by, text))); } catch (Exception ex) { } }
From source file:jp.co.nssol.h5.test.selenium.testcase.IndexTest.java
License:Apache License
@Test public void showStep7_2Page() throws InterruptedException { WebDriverWait wait = new WebDriverWait(getDriver(), 10); WebElement e = getDriver().findElement(By.linkText("recipe")); click(e);/*from w ww.java 2 s . co m*/ wait.until(ExpectedConditions.textToBePresentInElement(By.cssSelector("#contents > h2"), "")); assertThat("STEP7-2??????", querySelector("#contents > p").get(0).getText(), is("hifive?????")); }
From source file:jscover.server.WebDriverJasmineTestBase.java
License:Open Source License
@Test public void shouldRunJasmineTestAndStoreResult() throws IOException { File jsonFile = new File(getReportDir() + "/jscoverage.json"); if (jsonFile.exists()) jsonFile.delete();/* w w w. j a v a2 s .c o m*/ webClient.get("http://localhost:8081/jscoverage.html?" + getTestUrl()); String handle = webClient.getWindowHandle(); new WebDriverWait(webClient, 1).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("browserIframe")); new WebDriverWait(webClient, 1) .until(ExpectedConditions.presenceOfElementLocated(By.className("duration"))); new WebDriverWait(webClient, 1) .until(ExpectedConditions.textToBePresentInElement(By.className("duration"), "finished")); verifyJasmineTestsPassed(); webClient.switchTo().window(handle); new WebDriverWait(webClient, 1).until(ExpectedConditions.elementToBeClickable(By.id("storeTab"))); webClient.findElement(By.id("storeTab")).click(); new WebDriverWait(webClient, 1).until(ExpectedConditions.elementToBeClickable(By.id("storeButton"))); webClient.findElement(By.id("storeButton")).click(); new WebDriverWait(webClient, 2) .until(ExpectedConditions.textToBePresentInElement(By.id("storeDiv"), "Coverage data stored at")); webClient.get(format("http://localhost:8081/%s/jscoverage.html", getReportDir())); verifyTotal(webClient, 100, 0, 100); }