views:

483

answers:

2

Hi,

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?

+6  A: 

element instanceof RenderedWebElement should work.

hleinone
Works, but I still find this a bit annoying. I wonder what the reasoning is for not offering an WebElement.isDisplayed.
ponzao
This is not working but this interface delegates method isDisplayed and it works. Thanks for the hint. (+1)
Gaim
A: 

@Gaim Can you post your code snippet, I'm not able to get this working for me.

dock2
@dock2 This should either be a comment or a new question. What you want to do is `((RenderedWebElement) driver.findElement(findCondition)).isDisplayed()`.
ponzao