public static boolean isVisibleInViewport(WebElement element) {
        if (!isElementDisplayed(element)) {
            return false;
        }

        return PrimeSelenium.executeScript("var elem = arguments[0],"
                + "    box = elem.getBoundingClientRect(),"
                + "    cx = box.left + box.width / 2,"
                + "    cy = box.top + box.height / 2,"
                + "    e = document.elementFromPoint(cx, cy);"
                + "for (; e; e = e.parentElement) {"
                + "    if (e === elem) { return true; }"
                + "}"
                + "return false;", element);
    }
Is the Element visible in the current viewport??

@param element the WebElement to check
@return true if visible
primefaces-selenium/primefaces-selenium-core/src/main/java/org/primefaces/selenium/PrimeSelenium.java