/** * Is this web element present and visible on the screen This method will not throw an exception * if the element is not on the screen at all. If the element is not visible, the method will wait * a bit to see if it appears later on. */ @Override public boolean isVisible() { try { WebElement element = getElement(); return (element != null) && (element.isDisplayed()); } catch (ElementNotVisibleException e) { return false; } catch (NoSuchElementException e) { return false; } catch (StaleElementReferenceException se) { return false; } }
public boolean isPresent() { if (driverIsDisabled()) { return false; } try { WebElement element = getElement(); if (element == null) { return false; } element.isDisplayed(); return true; } catch (ElementNotVisibleException e) { return true; } catch (NotFoundException e) { return false; } catch (ElementNotFoundAfterTimeoutError timeoutError) { return false; } }