课程: Test Automation with Selenium WebDriver for Java

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Displayed

Displayed

- [Instructor] When interacting with web elements, sometimes you'll want to query the element state. One possible state is the visibility of that element. Here, we see in the dom, there's an input element that is not visible on the screen. Let's look at how to use web driver to get the visibility of an element. In the web element class, there's a method called "isDisplayed." So, let's find the element, then call that method. We can say, boolean isVisible = driver.findElement. We're going to find this one by name, and then we're going to call the isDisplayed method. If isDisplayed returns true, then the element is visible. If not, then the element is hidden.

内容