views:

269

answers:

1

Is there a cross browser solution to check if an element is visible using WebDriver? The solution for IE and firefox is to cast the object to a RenderedRemoteWebElement and then call the property Displayed.

I'm using the following methods to return if a element is visible:

/// <summary>
/// Check if the control is visible.
/// </summary>
public bool IsVisible()
{
    IWebElement control = mSelenium.FindElement(mFindBy);
    return ((RenderedRemoteWebElement)control).Displayed;
}

The problem is when I run this using Chrome, I get an exception when casting to type RenderedRemoteWebElement, this is not really the problem as I can catch this, but I need to a solution to check if an element is visible in chrome.

Thanks

+1  A: 

You should cast to IRenderedWebElement - Display is a property of that interface.

ZloiAdun