课程: Test Automation with Selenium WebDriver for Java

免费学习该课程!

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

Relative locators

Relative locators

- [Instructor] Sometimes it's difficult to construct a locator for a specific element, but it may be easier to describe its placement in relation to other elements on the page. Web Driver allows you to do just that with relative locators. The available options are above, which you use if you want to locate an element that appears above another specified elements. Below is to locate an element that appears below a different element. To left of, to find an element to the left of another element, to right of for an element to the right of an element, and near, which can be used to locate an element that is 50 pixels or less away from a specified element. However, the pixel distance is configurable. Notice on this page, we have two buttons labeled Submit or Submit ID Button. Let's use relative locators to get the second button. We see that this button does not have an ID, but it does have a name. Names are not required to be unique in the dom, so we'll enhance the query by also adding a…

内容