/** * 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 an AJAX request to complete and automatically unregisters the handlers. * <b>Note:</b> The behavior is undefined if more than one AJAX request was made after the the registration of the * handlers. */ void waitForRequestComplete() { checkState(hasHandlers(), "`ajaxStart` and `ajaxStop` handlers are not registered. Cannot detect if AJAX request is complete!"); WebElement bodyElement = browser.driver.findElement(By.tagName("body")); waitFor(ExpectedConditions.and( // Make sure that only a single AJAX request has previously occurred, this will be false if an AJAX // request was made while there are other outstanding AJAX requests. ExpectedConditions.attributeContains(bodyElement, START_OCCURRED_ATTRIBUTE, "true"), ExpectedConditions.attributeContains(bodyElement, START_ATTRIBUTE, "false"), ExpectedConditions.attributeContains(bodyElement, STOP_ATTRIBUTE, "true"))); // Any AJAX requests made while executing the following script will result in undefined behavior. executeScript("document.body.setAttribute(arguments[0], false);" + "document.body.setAttribute(arguments[1], false);" + "document.body.setAttribute(arguments[2], false);", START_ATTRIBUTE, STOP_ATTRIBUTE, START_OCCURRED_ATTRIBUTE); unregisterHandlers(); } }
/** * Returns if a {@value CHANGE_EVENT} event has not been fired for the element to which the hook is associated. * Note that this only detects the presence of firing of {@value CHANGE_EVENT} events and not does not keep track of * how many {@value CHANGE_EVENT} events are fired. */ private boolean isChangeEventNotFired() { WebDriverWait wait = new WebDriverWait(browser.driver, MAXIMUM_SECONDS_REQUIRED_FOR_ALL_CPUS_TO_FIRE_EVENT); try { wait.until(ExpectedConditions.attributeContains(By.tagName("body"), HOOK_ATTRIBUTE, "true")); return false; } catch (TimeoutException e) { return true; } }
public Boolean isElemAttribContaining(WebElement element, String attribute, String attributeValue) { try { return fluentWait.until(attributeContains(element, attribute, attributeValue)); } catch (Exception e) { return FALSE; } }
/** * Waiting for a certain text fragment to appear in the attribute * * @param element element * @param attributeName attribute name, for example "class" * @param partAttributeValue the expected value that the attribute should contains * @param message message in case the attribute value does not contain the expected value * @param timeout condition timeout in seconds */ public static void attributeContains(WebElement element, String attributeName, String partAttributeValue, String message, int timeout) { wait(ExpectedConditions.attributeContains(element, attributeName, partAttributeValue), message, timeout); }
/** * Waiting for a certain text fragment to appear in the attribute * * @param by locator to search for an item * @param attributeName attribute name, for example "class" * @param partAttributeValue the expected value that the attribute should contains * @param message message in case the attribute value does not contain the expected value * @param timeout condition timeout in seconds */ public static void attributeContains(By by, String attributeName, String partAttributeValue, String message, int timeout) { wait(ExpectedConditions.attributeContains(by, attributeName, partAttributeValue), message, timeout); }
private boolean isClosed() { return bobcatWait.isConditionMet(attributeContains(currentScope, CLASS, IS_CLOSED)); }
@Override public boolean isInEditMode() { return bobcatWait.isConditionMet(attributeContains(editModeButton, CLASS, IS_SELECTED)); } }
@Override public boolean isInPreviewMode() { return bobcatWait.isConditionMet(attributeContains(previewModeButton, CLASS, IS_SELECTED)); }
/** * 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); }
/** * 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); }