开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜