且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 WebDriver 检查元素是否可见

更新时间:2023-11-30 19:48:46

element instanceof RenderedWebElement 应该可以工作.

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?

element instanceof RenderedWebElement should work.