List of usage examples for org.openqa.selenium WebElement isDisplayed
boolean isDisplayed();
From source file:myfightinglayoutbugs.DetectElementsWithInvisibleFocus.java
License:Apache License
private FocusedElement toFocusedElement(@Nonnull WebElement activeElement, WebPage webPage) { // I don't trust WebDriver, that's why I determine the offset, width and height with jQuery too ... @SuppressWarnings("unchecked") Map<String, Object> temp = (Map<String, Object>) JsonHelper .parse((String) webPage .executeJavaScript(/*from w ww . ja va 2 s . c o m*/ "var $element = jQuery(arguments[0]);\n" + "var offset = $element.offset();\n" + "var $temp = $element.clone(false).wrap('<div></div>').parent();\n" + "try {\n" + " return JSON.stringify({\n" + " x: offset.left,\n" + " y: offset.top,\n" + " w: $element.width(),\n" + " h: $element.height(),\n" + " html: $temp.html()\n" + " });\n" + "} finally {\n" + " $temp.remove();\n" + "}", activeElement)); int x = ((Number) temp.get("x")).intValue(); int y = ((Number) temp.get("y")).intValue(); int w = ((Number) temp.get("w")).intValue(); int h = ((Number) temp.get("h")).intValue(); String html = (String) temp.get("html"); if (activeElement.isDisplayed()) { //Point location = //activeElement.getLocation().getX(); //Dimension size = activeElement.getSize().height; int x1 = Math.min(activeElement.getLocation().getX(), x); int y1 = Math.min(activeElement.getLocation().getY(), y); int x2 = Math.max(activeElement.getLocation().getX() + activeElement.getSize().getWidth(), x + w) - 1; int y2 = Math.max(activeElement.getLocation().getY() + activeElement.getSize().getHeight(), y + h) - 1; return new FocusedElement(activeElement, new RectangularRegion(x1, y1, x2, y2), html); } else { return new FocusedElement(activeElement, NOT_DISPLAYED, html); } }
From source file:net.atf4j.webdriver.page.AbstractPageObject.java
License:Open Source License
/** * Verify.//from w ww . jav a 2 s .co m * * @param webElement the web element \* @return true, if successful, * otherwise false. * @return true, if successful, otherwise false. */ protected boolean verifyElement(final WebElement webElement) { verifyNotNull(webElement); final boolean testStatus = true; verifyNotNull(webElement); verifyNotNull(webElement.toString()); assertTrue(webElement.isDisplayed()); assertTrue(webElement.isEnabled()); return testStatus; }
From source file:net.codestory.simplelenium.filters.LazyShould.java
License:Apache License
private static String displayedStatus(WebElement element) { return element.isDisplayed() ? "displayed" : "not displayed"; }
From source file:nl.surfnet.coin.selenium.SeleniumSupport.java
License:Apache License
protected void waitForElementDisplay(WebElement element) { while (!element.isDisplayed()) { LOG.debug("waiting for element " + element.getAttribute("id")); //sorry I need to eat your CPU here try {/*from w w w . j ava 2 s . c om*/ Thread.sleep(100); } catch (InterruptedException e) { //ignored } } }
From source file:omelet.common.ExpectedConditionExtended.java
License:Apache License
/*** * wait for the WebElement to be Clickable * //from w ww .j a va 2 s . co m * @param element * : WebElement * @return */ public static ExpectedCondition<WebElement> elementToBeClickable(final WebElement element) { return new ExpectedCondition<WebElement>() { public WebElement apply(WebDriver driver) { try { if (element.isDisplayed() && element.isEnabled()) { return element; } else { return null; } } catch (StaleElementReferenceException e) { LOGGER.error(e); return null; } catch (NoSuchElementException e) { LOGGER.error(e); return null; } } @Override public String toString() { return "Element is not enabled"; } }; }
From source file:omelet.common.ExpectedConditionExtended.java
License:Apache License
/** * An expectation for checking that an element is either invisible or not * present in the DOM./*from www.j ava2 s. c o m*/ * * @param locator * used to find the element */ public static ExpectedCondition<Boolean> invisibilityOfElementLocated(final WebElement webelement) { return new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver driver) { try { return !(webelement.isDisplayed()); } catch (NoSuchElementException e) { LOGGER.error(e); return true; } catch (StaleElementReferenceException e) { // Returns true , need to check if stale means invisible LOGGER.error(e); return true; } } @Override public String toString() { return "element to no longer be visible: " + webelement.toString(); } }; }
From source file:omelet.common.ExpectedConditionExtended.java
License:Apache License
/*** * This method accepts n number of WebElements and check for click ability * if any of the WebElement is not click able will return false * // www . j a va 2s . c o m * @param elements * @return */ public static ExpectedCondition<Boolean> elementsToBeClickable(final WebElement... elements) { final List<Boolean> statusList = new ArrayList<Boolean>(); return new ExpectedCondition<Boolean>() { final StringBuilder sb = new StringBuilder(); public Boolean apply(WebDriver driver) { for (WebElement w : elements) { try { if (w.isDisplayed() && w.isEnabled()) { statusList.add(true); } else { statusList.add(false); } } catch (StaleElementReferenceException e) { LOGGER.error(e); statusList.add(false); } } if (statusList.contains(false)) { statusList.clear(); return false; } return true; } @Override public String toString() { return "elements to be clickable: " + sb; } }; }
From source file:omelet.common.ExpectedConditionExtended.java
License:Apache License
/*** * Check clikability for the list of WebElement * //from w w w . ja v a 2 s. co m * @param elements * @return */ public static ExpectedCondition<Boolean> elementToBeClickable(final List<WebElement> elements) { final List<Boolean> statusList = new ArrayList<Boolean>(); return new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver driver) { if (elements.isEmpty()) { return false; } statusList.clear(); for (WebElement w : elements) { try { if (w != null && w.isEnabled() && w.isDisplayed()) { statusList.add(true); } else { return false; } } catch (StaleElementReferenceException e) { LOGGER.error(e); return false; } } LOGGER.debug( "element size is:" + elements.size() + " and is sucesfull list is:" + statusList.size()); return statusList.size() == elements.size() ? true : false; } @Override public String toString() { return "One of the Element is not clickable:"; } }; }
From source file:omelet.common.ExpectedConditionExtended.java
License:Apache License
/*** * Check if all the element in the List are displayed * /* w w w. j av a2 s . co m*/ * @param elements * @return */ public static ExpectedCondition<Boolean> elementToBeDisplayed(final List<WebElement> elements) { final List<Boolean> statusList = new ArrayList<Boolean>(); return new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver driver) { for (WebElement w : elements) { try { if (w != null && w.isDisplayed()) { statusList.add(true); } else { return null; } } catch (StaleElementReferenceException e) { LOGGER.error(e); return null; } } return statusList.size() == elements.size() ? true : false; } @Override public String toString() { return "One of the Element is not clickable:"; } }; }
From source file:org.alfresco.po.PageElement.java
License:Open Source License
public boolean isDisplayed(WebElement element) { try {// w w w . j a v a2 s . com return element.isDisplayed(); } catch (Exception e) { //Ignore. } return false; }