List of usage examples for org.openqa.selenium WebElement isDisplayed
boolean isDisplayed();
From source file:com.smash.revolance.ui.explorer.PageParser.java
License:Open Source License
public List<Element> getElements() throws Exception { final Logger logger = page.getUser().getLogger(); long mark = System.currentTimeMillis(); List<Element> elements = new ArrayList<Element>(); List<WebElement> webElements = BotHelper.getRawElements(page.getUser().getBot(), page); int idx = 0;//from w w w . jav a2 s . c o m int elementCount = webElements.size(); for (WebElement element : webElements) { idx++; try { if (element.isDisplayed()) { Class<? extends Element> elemImpl = Element.getImplementation(element); if (elemImpl != null) { Element elem = elemImpl.getConstructor(Page.class, WebElement.class).newInstance(page, element); if (elem.getArea() > 0) { // handleAddition( elements, elem ); elements.add(elem); } } } } catch (StaleElementReferenceException e) { logger.log(Level.ERROR, e); } finally { logger.log(Level.INFO, "Retrieving page element ( " + idx + "/" + elementCount + " )"); } } long duration = (System.currentTimeMillis() - mark) / 1000; logger.log(Level.INFO, "Retrieving page elements [Done] [Duration: " + duration + "sec]"); return elements; }
From source file:com.smash.revolance.ui.model.element.api.Button.java
License:Open Source License
public static List<Element> getButtons(Page page) throws Exception { List<Element> buttons = new ArrayList<Element>(); for (WebElement element : BotHelper.getRawElements(page.getUser().getBot(), page)) { try {/* ww w .j ava 2 s. c o m*/ if (element.isDisplayed() && getImplementation(element).getClass().getName().contentEquals(Button.class.getName())) { Button button = new Button(page, element); if (button.getArea() > 0) { if (!Button.containsButton(buttons, button)) { buttons.add(button); } } } } catch (StaleElementReferenceException e) { System.err.println(e); } } return buttons; }
From source file:com.smash.revolance.ui.model.element.api.Element.java
License:Open Source License
public static boolean isVisible(WebElement element) { return element.isDisplayed(); }
From source file:com.smash.revolance.ui.model.element.api.Image.java
License:Open Source License
public static List<Element> getImages(Page page) throws Exception { List<Element> images = new ArrayList<Element>(); for (WebElement element : BotHelper.getRawImages(page.getUser().getBot(), page)) { try {//from w ww .j a v a 2s .c o m if (element.isDisplayed() && Element.getImplementation(element).getClass().getName() .contentEquals(Image.class.getName())) { Image image = new Image(page, element); if (image.getArea() > 0) { if (!Image.containsImage(images, image)) { images.add(image); } } } } catch (StaleElementReferenceException e) { System.err.println(e); } } return images; }
From source file:com.smash.revolance.ui.model.element.api.Link.java
License:Open Source License
public static List<Element> getLinks(Page page) throws Exception { List<Element> links = new ArrayList<Element>(); for (WebElement element : BotHelper.getRawLinks(page.getUser().getBot(), page)) { try {//from w w w . j av a 2 s.c o m if (element.isDisplayed() && getImplementation(element).getClass().getName().contentEquals(Link.class.getName())) { Link link = new Link(page, element); if (link.getArea() > 0) { if (!containsLink(links, link.getContent())) { links.add(link); } } } } catch (StaleElementReferenceException e) { System.err.println(e); } } return links; }
From source file:com.smash.revolance.ui.model.helper.BotHelper.java
License:Open Source License
public static WebElement findMatchingElement(Bot bot, Element element) throws Exception { WebElement webelement = findWebElement(bot, element); if (webelement.isDisplayed() && webelement.isDisplayed()) { return webelement; } else {/*from w w w .j a v a 2 s. c o m*/ throw new ElementNotVisibleException("Element: " + webelement + " is not visible."); } }
From source file:com.springer.omelet.common.ExpectedConditionExtended.java
License:Apache License
/*** * wait for the WebElement to be Clickable * /*from ww w.j a va 2s . c o 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) { return null; } catch (NoSuchElementException e) { return null; } } @Override public String toString() { return "Element is not enabled"; } }; }
From source file:com.springer.omelet.common.ExpectedConditionExtended.java
License:Apache License
/** * An expectation for checking that an element is either invisible or not * present in the DOM./* www . ja v a2 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) { return true; } catch (StaleElementReferenceException e) { // Returns true , need to check if stale means invisible return true; } } @Override public String toString() { return "element to no longer be visible: " + webelement.toString(); } }; }
From source file:com.springer.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 * //from www .ja v a2s .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) { 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:com.springer.omelet.common.ExpectedConditionExtended.java
License:Apache License
/*** * Check clikability for the list of WebElement * @param elements// www. ja v a2s. co m * @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.size() == 0) 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) { 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:"; } }; }