Checking if an element is visible in Chrome using Selenium Remote WebDriver
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
You should cast to IRenderedWebElement
- Display is a property of that interface.
精彩评论