/** * Waits for Ajax loaded panel to be expanded. The panel is expanded when Ajax loading finishes, * which is identified by the removal of Ajax class in the element. * * @param panelId the Id of panel element * @param ajaxClass the class removed from {@code panelElement} when Ajax loading finished */ public void waitForAjaxLoadedPanelToExpand(String panelId, String ajaxClass) { WebElement panelElement = browser.driver.findElement(By.id(panelId)); waitFor(ExpectedConditions.not(ExpectedConditions.attributeContains(panelElement, "class", ajaxClass))); }
/** * Waits for text contained in the element to disappear from the page, or timeout. */ public void waitForTextContainedInElementAbsence(By by, String text) { waitFor(ExpectedConditions.not(ExpectedConditions.textToBePresentInElementLocated(by, text))); }
/** * Waits the given number of seconds for the given condition to become * false. Use e.g. as {@link #waitUntilNot(ExpectedCondition)}. * * @param condition * the condition to wait for to become false * @param timeoutInSeconds * the number of seconds to wait * @param <T> * the return type of the expected condition */ protected <T> void waitUntilNot(ExpectedCondition<T> condition, long timeoutInSeconds) { waitUntil(ExpectedConditions.not(condition), timeoutInSeconds); }
public static ExpectedCondition<Boolean> visibilityOfElementLocated(final By locator) { return ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(locator)); }
/** * Awaiting disappearance in attribute of a certain text fragment * * @param by locator to search for an item * @param attributeName attribute name, for example "class" * @param partAttributeValue the expected value that the attribute should not contains * @param message message if the attribute value contains the expected value * @param timeout condition timeout in seconds */ public static void attributeNotContains(By by, String attributeName, String partAttributeValue, String message, int timeout) { wait(ExpectedConditions.not(ExpectedConditions.attributeContains(by, attributeName, partAttributeValue)), message, timeout); }
/** * Waiting for missing expected text in the item * * @param element element * @param text text that should be missing from the element * @param message message in case text is present in the element after waiting * @param timeout condition timeout in seconds */ public static void textNotContains(WebElement element, String text, String message, int timeout) { wait(ExpectedConditions.not(ExpectedConditions.textToBePresentInElement(element, text)), message, timeout); }
/** * Waits for text inequality in the element * * @param by locator to search for an item * @param text text that should be missing from the element * @param message message in case text is present in the element after waiting * @param timeout condition timeout in seconds */ public static void textNotEquals(By by, String text, String message, int timeout) { wait(ExpectedConditions.not(ExpectedConditions.textToBe(by, text)), message, timeout); }
/** * Awaiting disappearance in attribute of a certain text fragment * * @param element element * @param attributeName attribute name, for example "class" * @param partAttributeValue the expected value that the attribute should not contains * @param message message if the attribute value contains the expected value * @param timeout condition timeout in seconds */ public static void attributeNotContains(WebElement element, String attributeName, String partAttributeValue, String message, int timeout) { wait(ExpectedConditions.not(ExpectedConditions.attributeContains(element, attributeName, partAttributeValue)), message, timeout); }
/** * Waiting for missing expected text in the item * * @param by locator to search for an item * @param text text that should be missing from the element * @param message message in case text is present in the element after waiting * @param timeout condition timeout in seconds */ public static void textNotContains(By by, String text, String message, int timeout) { wait(ExpectedConditions.not(ExpectedConditions.textToBePresentInElementLocated(by, text)), message, timeout); }
/** * Waiting for missing expected text in the item * * @param xpath element xpath * @param text text that should be missing from the element * @param message message in case text is present in the element after waiting * @param timeout condition timeout in seconds */ public static void textNotContains(String xpath, String text, String message, int timeout) { wait(ExpectedConditions.not(ExpectedConditions.textToBePresentInElementLocated(By.xpath(xpath), text)), message, timeout); }
public Locomotive click(By by) { waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by))) .waitForCondition(ExpectedConditions.elementToBeClickable(by)); waitForElement(by).click(); return this; }
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 void waitUntilNotVisible() { page.driverWait(VISIBLE_TIMEOUT).until(not(visibilityOf(element()))); }
/** * * @param element a {@link org.openqa.selenium.WebElement} object. */ public static void waitUntilElementGetInvisible(WebElement element) { new WebDriverWait(PageFactory.getDriver(), PageFactory.getTimeOutInSeconds()) .until(ExpectedConditions.not(ExpectedConditions.visibilityOf(element))); }
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; }
public Locomotive selectOptionByText(By by, String text) { Select box = new Select(waitForElement(by)); waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by))) .waitForCondition(ExpectedConditions.elementToBeClickable(by)); box.selectByVisibleText(text); return this; }
public Locomotive selectOptionByValue(By by, String value) { Select box = new Select(waitForElement(by)); waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by))) .waitForCondition(ExpectedConditions.elementToBeClickable(by)); box.selectByValue(value); 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; }