public void waitForElementToBeClickable(WebElement element) { waitFor(ExpectedConditions.elementToBeClickable(element)); }
/** * Wait until element present * * @param element element * @param message message in case the element did not appear after waiting * @param timeout condition timeout in seconds */ public static void clickable(WebElement element, String message, int timeout) { wait(ExpectedConditions.elementToBeClickable(element), message, timeout); }
/** * Wait until element present * * @param by locator to search for an item * @param message message in case the element did not appear after waiting * @param timeout condition timeout in seconds */ public static void clickable(By by, String message, int timeout) { wait(ExpectedConditions.elementToBeClickable(by), message, timeout); }
@Test public void testLandscapeRightRotation() { new WebDriverWait(driver, 20).until(ExpectedConditions .elementToBeClickable(driver.findElementById("android:id/content") .findElement(MobileBy.AccessibilityId("Graphics")))); DeviceRotation landscapeRightRotation = new DeviceRotation(0, 0, 90); driver.rotate(landscapeRightRotation); assertEquals(driver.rotation(), landscapeRightRotation); }
@Test public void testLandscapeLeftRotation() { new WebDriverWait(driver, 20).until(ExpectedConditions .elementToBeClickable(driver.findElementById("android:id/content") .findElement(MobileBy.AccessibilityId("Graphics")))); DeviceRotation landscapeLeftRotation = new DeviceRotation(0, 0, 270); driver.rotate(landscapeLeftRotation); assertEquals(driver.rotation(), landscapeLeftRotation); }
@Test public void testPortraitUpsideDown() { new WebDriverWait(driver, 20).until(ExpectedConditions .elementToBeClickable(driver.findElementById("android:id/content") .findElement(MobileBy.AccessibilityId("Graphics")))); DeviceRotation landscapeRightRotation = new DeviceRotation(0, 0, 180); driver.rotate(landscapeRightRotation); assertEquals(driver.rotation(), landscapeRightRotation); }
.AccessibilityId("Make a Popup!"))); MobileElement popUpElement = driver.findElement(MobileBy.AccessibilityId("Make a Popup!")); wait.until(ExpectedConditions.elementToBeClickable(popUpElement)).click(); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath(".//*[@text='Search']"))).click(); By.xpath("//*[@text='Clicked popup menu item Search']")))); wait.until(ExpectedConditions.elementToBeClickable(popUpElement)).click(); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath(".//*[@text='Add']"))).click(); .presenceOfElementLocated(By.xpath("//*[@text='Clicked popup menu item Add']")))); wait.until(ExpectedConditions.elementToBeClickable(popUpElement)).click(); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath(".//*[@text='Edit']"))).click();
@Override public ExpectedCondition<Boolean> isClickable() { return new BooleanConditionWrapper(ExpectedConditions.elementToBeClickable(element), getNegation(), NoSuchElementException.class); }
/** * Wait until element present * * @param xpath element xpath * @param message message in case the element did not appear after waiting * @param timeout condition timeout in seconds */ public static void clickable(String xpath, String message, int timeout) { wait(ExpectedConditions.elementToBeClickable(By.xpath(xpath)), message, timeout); }
public static void waitForElementToBeClickable(WebDriver webDriver, By elementLocator, long timeOut) { WebDriverWait wait = new WebDriverWait(webDriver, timeOut); wait.until(ExpectedConditions.elementToBeClickable(elementLocator)); } }
public static void waitForElementClickable(WebDriver webdriver, By by, long timeout) { WebDriverWait wait = new WebDriverWait(webdriver, timeout); wait.until(ExpectedConditions.elementToBeClickable(by)); } }
/** Method to Explicitly wait for element to be enabled=click * @param accessType : String : Locator type (id, name, class, xpath, css) * @param accessName : String : Locator value * @param duration : String : Time to wait for element to be clickable */ public void waitForElementToClick(String accessType,String accessName,String duration) { By byEle = getelementbytype(accessType, accessName); WebDriverWait wait = (new WebDriverWait(driver,Integer.parseInt(duration)*1000)); wait.until(ExpectedConditions.elementToBeClickable(byEle)); }
public boolean waitUntilElementToBeClickable(WebElement webElement, long seconds) { return innerTimeoutOperation(() -> { WebDriverWait webDriverWait = new WebDriverWait(driver, seconds, 0L); webDriverWait.until(ExpectedConditions.elementToBeClickable(webElement)); return webDriverWait; }); }
/** * Wait until element present * * @param webElement Desired web element * @param timeout Timeout in seconds */ public static void waitUntilElementToBeClickable(WebElement webElement, int timeout) { new WebDriverWait(PageFactory.getDriver(), timeout). until(ExpectedConditions.elementToBeClickable(webElement)); }
public static void waitForElementEditable(final HtmlElement element) { Assert.assertNotNull(element, "Element can't be null"); TestLogging.logWebStep( "wait for " + element.toString() + " to be editable.", false ); final WebDriverWait wait = new WebDriverWait(WebUIDriver.getWebDriver(), EXPLICT_WAIT_TIMEOUT); wait.until(ExpectedConditions.elementToBeClickable(element.getBy())); }
public Locomotive setText(By by, String text) { waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by))) .waitForCondition(ExpectedConditions.elementToBeClickable(by)); WebElement element = waitForElement(by); element.clear(); element.sendKeys(text); return this; }
public Locomotive check(By by) { if (!isChecked(by)) { waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by))) .waitForCondition(ExpectedConditions.elementToBeClickable(by)); waitForElement(by).click(); assertTrue(by.toString() + " did not check!", isChecked(by)); } return this; }
public Locomotive uncheck(By by) { if (isChecked(by)) { waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by))) .waitForCondition(ExpectedConditions.elementToBeClickable(by)); waitForElement(by).click(); assertFalse(by.toString() + " did not uncheck!", isChecked(by)); } return this; }
@Override public Locomotive selectOptionByIndex(By by, Integer i) { Select box = new Select(waitForElement(by)); waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by))) .waitForCondition(ExpectedConditions.elementToBeClickable(by)); box.selectByIndex(i); return this; }
/** * Checks if the element is clickable on the browser */ public WebElement forElementClickable(By by, int timeout) { changeImplicitWait(250, TimeUnit.MILLISECONDS); try { return new WebDriverWait(driver, timeout).until(ExpectedConditions.elementToBeClickable(by)); } finally { restoreDeaultImplicitWait(); } }