/** * Waits for the element to appear in the page, up to the timeout specified. */ public WebElement waitForElementPresence(By by) { return waitFor(ExpectedConditions.presenceOfElementLocated(by)); }
@Test public void hideKeyboardWithParametersTest() { new WebDriverWait(driver, 30) .until(ExpectedConditions.presenceOfElementLocated(By.id("IntegerA"))) .click(); driver.hideKeyboard(HideKeyboardStrategy.PRESS_KEY, "Done"); }
@Ignore @Test public void whenIOSHybridAppIsLaunched() { assertTrue(check(serverAppCapabilitiesSupplier, appFileSupplierFunction.apply(webViewApp), (by, aClass) -> { new WebDriverWait(driver, 30) .until(ExpectedConditions.presenceOfElementLocated(id("login"))) .click(); driver.findElementByAccessibilityId("webView").click(); new WebDriverWait(driver, 30) .until(ExpectedConditions .presenceOfElementLocated(AccessibilityId("Webview"))); try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } driver.getContextHandles().forEach((handle) -> { if (handle.contains("WEBVIEW")) { driver.context(handle); } }); return commonPredicate.test(by, aClass); }, partialLinkText("login"), IOSElement.class)); }
@Test public void webViewPageTestCase() throws InterruptedException { new WebDriverWait(driver, 30) .until(ExpectedConditions.presenceOfElementLocated(By.id("login"))) .click(); driver.findElementByAccessibilityId("webView").click(); new WebDriverWait(driver, 30) .until(ExpectedConditions.presenceOfElementLocated(MobileBy.AccessibilityId("Webview"))); findAndSwitchToWebView(); WebElement el = driver.findElementByPartialLinkText("login"); assertTrue(el.isDisplayed()); } }
driver.startActivity(activity); wait.until(ExpectedConditions.presenceOfElementLocated(MobileBy .AccessibilityId("Make a Popup!"))); MobileElement popUpElement = driver.findElement(MobileBy.AccessibilityId("Make a Popup!")); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath(".//*[@text='Search']"))).click(); assertNotNull(wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//*[@text='Clicked popup menu item Search']")))); By.xpath(".//*[@text='Add']"))).click(); assertNotNull(wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("//*[@text='Clicked popup menu item Add']")))); By.xpath(".//*[@text='Edit']"))).click(); assertNotNull(wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("//*[@text='Clicked popup menu item Edit']")))); .presenceOfElementLocated(By.xpath("//*[@text='Clicked popup menu item Share']"))));
/** * This method will wait until an element is present on the screen, though not necessarily visible. */ public void waitForPresenceOf(final By byElementCriteria) { WebDriverWait wait = new WebDriverWait(driver, waitForTimeout.getSeconds()); wait.until(ExpectedConditions.presenceOfElementLocated(byElementCriteria)); }
private WebElement doFindElement() { if (timeout > 0) { return new WebDriverWait(webDriver, timeout) .until(ExpectedConditions.presenceOfElementLocated(by)); } else { return webDriver.findElement(by); } }
public static void waitForElementToBePresent(WebDriver webDriver, By elementLocator, long timeOut) throws WebDriverException { WebDriverWait wait = new WebDriverWait(webDriver, timeOut); wait.until(ExpectedConditions.presenceOfElementLocated(elementLocator)); }
/** * This method will wait until an element is present on the screen, though not necessarily visible. */ public void waitForPresenceOf(final By byElementCriteria) { WebDriverWait wait = new WebDriverWait(driver, (long)(waitForTimeoutInMilliseconds/1000)); wait.until(ExpectedConditions.presenceOfElementLocated(byElementCriteria)); // waitForCondition().until(elementPresent(byElementCriteria)); }
/** * This method will wait until a given element is present in the page for a given amount of time * * @param by Element to be present in the current page * @param waitTimeSec Time to wait in seconds */ private void waitTillElementPresent(By by, int waitTimeSec) { WebDriverWait wait = new WebDriverWait(driver, waitTimeSec); wait.until(ExpectedConditions.presenceOfElementLocated(by)); }
/** * Wait until element will be present on the DOM of a page * * @param xpath element xpath * @param message message in case there is no text in the element after waiting * @param timeout condition timeout in seconds */ public static void presence(String xpath, String message, int timeout) { wait(ExpectedConditions.presenceOfElementLocated(By.xpath(xpath)), message, timeout); }
/** * @param pBy * @param timeoutInSeconds */ public void driverWaitElementPresent(By pBy, int timeoutInSeconds) { driverWait(timeoutInSeconds).until(ExpectedConditions.presenceOfElementLocated(pBy)); }
protected CookieImplantOutput waitForCookieImplantOutput(WebDriver driver, int timeOutInSeconds) { By by = byOutputStatus(CookieProcessingStatus.all_implants_processed::equals); Function<? super WebDriver, WebElement> fn = ExpectedConditions.presenceOfElementLocated(by); WebElement outputElement = new WebDriverWait(driver, timeOutInSeconds) .until(fn); String outputJson = outputElement.getText(); CookieImplantOutput output = gson.fromJson(outputJson, CookieImplantOutput.class); return output; }
@Override public void checkReachableWebPage() { selenium.getDriverWait().withTimeout(Duration.ofSeconds(60)).until(ExpectedConditions.presenceOfElementLocated(By.className("navbar-pf-vertical"))); } }
/** method to get element status - displayed? @param accessType : String : Locator type (id, name, class, xpath, css) @param accessName : String : Locator value @return Boolean */ public boolean isElementDisplayed(String accessType,String accessName) { element = wait.until(ExpectedConditions.presenceOfElementLocated(getelementbytype(accessType, accessName))); return element.isDisplayed(); }
/** Method to scroll page to particular element * @param accessType : String : Locator type (id, name, class, xpath, css) * @param accessName : String : Locator value */ public void scrollToElement(String accessType, String accessName) { element = wait.until(ExpectedConditions.presenceOfElementLocated(getelementbytype(accessType, accessName))); JavascriptExecutor executor = (JavascriptExecutor)driver; executor.executeScript("arguments[0].scrollIntoView();", element); }
@Override public boolean isComponentPresent(String locator, long seconds) { try { WebDriverWait wait = new WebDriverWait(driver, seconds); wait.until(ExpectedConditions.presenceOfElementLocated(determineLocator(locator))); return true; } catch (Exception e) { return false; } }
/** * This method will wait until an element is present on the screen, though not necessarily visible. */ public void waitForPresenceOf(final By byElementCriteria) { WebDriverWait wait = new WebDriverWait(driver, waitForTimeout.in(TimeUnit.SECONDS)); wait.until(ExpectedConditions.presenceOfElementLocated(byElementCriteria)); }
public static void waitForElementPresent(final HtmlElement element) { Assert.assertNotNull(element, "Element can't be null"); TestLogging.logWebStep( "wait for " + element.toString() + " to be present.", false ); final WebDriverWait wait = new WebDriverWait(WebUIDriver.getWebDriver(), EXPLICT_WAIT_TIMEOUT); wait.until( ExpectedConditions.presenceOfElementLocated( element.getBy() ) ); }
@Override public Boolean apply(@Nullable WebDriver input) { return ExpectedConditions.presenceOfElementLocated(By.className(cssClassName)) .apply(input) .isDisplayed(); } });