Search code examples
javaseleniumwebdriver

How to check if an element is visible with WebDriver


With WebDriver from Selenium 2.0a2 I am having trouble checking if an element is visible.

WebDriver.findElement returns a WebElement, which unfortunately doesn't offer an isVisible method. I can go around this by using WebElement.clear or WebElement.click both of which throw an ElementNotVisibleException, but this feels very dirty.

Any better ideas?


Solution

  • element instanceof RenderedWebElement should work.