List of usage examples for org.openqa.selenium WebElement isDisplayed
boolean isDisplayed();
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Gets the element by text.//from w w w .jav a 2 s . c om * * @param driver the driver * @param locator the locator * @param innerText the inner text * @param timeout the timeout * @return the element by text */ public static WebElement getElementByText(final WebDriver driver, final By locator, final String innerText, final Timeout timeout) { for (final WebElement webElement : getElements(driver, locator, timeout)) { if (webElement.isDisplayed() && webElement.isEnabled() && webElement.getText().trim().equalsIgnoreCase(innerText)) { return webElement; } } return null; }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Gets the element by text contains.//from ww w .j a v a 2 s. co m * * @param driver the driver * @param locator the locator * @param innerText the inner text * @param timeout the timeout * @return the element by text contains */ public static WebElement getElementByTextContains(final WebDriver driver, final By locator, final String innerText, final Timeout timeout) { for (final WebElement webElement : getElements(driver, locator, timeout)) { if (webElement.isDisplayed() && webElement.isEnabled() && webElement.getText().trim().contains(innerText)) { return webElement; } } return null; }
From source file:com.coderoad.automation.rocketTruedx.RocketTruedxNaBasePage.java
License:Open Source License
/** * this method selects the options from the combobox. * /*from w w w .j av a 2s .co m*/ * @param dropDown the drop down * @param option the option */ protected void selectOptionIn(WebElement dropDown, String option) { String triggerId = dropDown.getAttribute("id"); WebElement arrow = dropDown.findElement(By.id(triggerId)); if (arrow.isDisplayed()) { arrow.click(); } WaitUtil.waitUntil(5); List<WebElement> options = getDriver().findElements(By.xpath("//li[@role='option']")); for (WebElement opt : options) { if (opt.getText().equalsIgnoreCase(option)) { click(opt); WaitUtil.waitUntil(2); break; } } }
From source file:com.cognifide.qa.bb.aem.expectedconditions.ContentFinderActions.java
License:Apache License
/** * Collapses content finder and checks if collapse button hides. * * @return condition for content finder to be collapsed *///from w w w . j a v a 2 s .co m public static ExpectedCondition<Boolean> collapse() { return driver -> { WebElement collapseButton = driver.findElement(By.cssSelector(COLLAPSE_BUTTON_CSS)); collapseButton.click(); return !collapseButton.isDisplayed(); }; }
From source file:com.cognifide.qa.bb.aem.expectedconditions.ContentFinderActions.java
License:Apache License
/** * Expands content finder and checks if expand button hides. * * @return condition for content finder to be expanded *//*ww w. jav a 2 s . c o m*/ public static ExpectedCondition<Boolean> expand() { return new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver driver) { WebElement expandButton = driver.findElement(By.cssSelector(EXPAND_BUTTON_CSS)); expandButton.click(); return !expandButton.isDisplayed(); } @Override public String toString() { return String.format(VIEW_IS_NOT_READY); } }; }
From source file:com.cognifide.qa.bb.aem.expectedconditions.WindowActions.java
License:Apache License
/** * Clicks on button and check if its displayed. * <br>//from w w w .j a v a 2s. c o m * When button is not available it returns true. * * @param button button to click on * @return display of button or true if provided web element is not available */ public static ExpectedCondition<Boolean> clickButton(final WebElement button) { return input -> { try { button.click(); return !button.isDisplayed(); } catch (NoSuchElementException | StaleElementReferenceException e) { LOG.debug("Button is not available at the moment: '{}'", e); return true; } }; }
From source file:com.cognifide.qa.bb.aem.touch.siteadmin.aem61.SiteadminToolbar.java
License:Apache License
public void movePage(String destination) { WebElement moveButton = getMoveButton(); if (!moveButton.isDisplayed()) { getMoreButton().click();/*from w w w . j a va2 s. com*/ } moveButton.click(); movePageWizard.moveToDestination(destination); }
From source file:com.cognifide.qa.bb.aem.touch.util.Conditions.java
License:Apache License
/** * Checks if a WebElement is ready to be operated on, ie. is visible and not stale and returns that * element./*from ww w . j av a 2 s . c o m*/ * * @param element WebElement to be checked * @return checked element */ public WebElement elementReady(WebElement element) { return bobcatWait.withTimeout(Timeouts.MEDIUM).until(ignored -> { try { return element.isDisplayed() ? element : null; } catch (StaleElementReferenceException e) { return null; } }); }
From source file:com.cognifide.qa.bb.aem.ui.AemDialog.java
License:Apache License
/** * Clicks button at the bottom of edit Window and expect for dialog to disappear. * * @param buttonText button label/*w ww . j a v a 2 s. c o m*/ * @return Returns this dialog instance. */ public AemDialog clickDialogFooterButton(final String buttonText) { final WebElement footerButton = getFooterButtonWebElement(buttonText); bobcatWait.withTimeout(Timeouts.BIG).until((ExpectedCondition<Object>) input -> { try { footerButton.click(); footerButton.isDisplayed(); return Boolean.FALSE; } catch (NoSuchElementException | StaleElementReferenceException | ElementNotVisibleException e) { LOG.debug("Dialog footer button is not available: {}", e); return Boolean.TRUE; } }, 2); bobcatWait.withTimeout(Timeouts.MEDIUM).until(CommonExpectedConditions.noAemAjax()); return this; }
From source file:com.cognifide.qa.bb.aem.ui.wcm.SiteAdminPage.java
License:Apache License
/** * Activates the page with provided title by selecting it and pressing Activate Later button in * Activate drop down.//from w w w.j av a 2 s . co m * * @param title title of the page * @param day day in format dd/mm/yy * @param time time in format hh:mm a (10:12 AM) * @return this SiteadminPage */ public SiteAdminPage activatePageLater(String title, String day, String time) { grid.selectPageByTitle(title); bobcatWait.withTimeout(Timeouts.MEDIUM).until(driver -> { grid.getActionBar().expandDropDown(SiteAdminButtons.ACTIVATE); WebElement button = webDriver.findElement(SiteAdminButtons.ACTIVATE_LATER.getLocator()); return button.isDisplayed() && !button.findElement(By.xpath("..")) .getAttribute(HtmlTags.Attributes.CLASS).contains("x-item-disabled"); }); grid.getActionBar().clickDropDownOption(SiteAdminButtons.ACTIVATE_LATER); replicateLaterWindow.fillDay(day); replicateLaterWindow.fillTime(time); replicateLaterWindow.confirm(); grid.waitForLoaderNotPresent(); waitForPageStatus(title, PageStatus.SCHEDULED_ACTIVATION); return this; }