January 2018
Beginner to intermediate
354 pages
7h 59m
English
When defining locators for a WebElement using XPath or CSS, there are many variations of a locator that can be used. Let's look at a couple of web pages and define a single attribute XPath and CSS locator for it. The following web page is a sample web application at www.practiceselenium.com, running in Firefox:

The Inspector frame shows that for the Welcome link, we have href, data-title, data-pageid, and data-url attributes to work with. Let's build the XPath and CSS locators using these attributes:
@FindBy(xpath = "//a[@href='welcome.html']")@FindBy(css = "a[href='welcome.html']")protected M welcome; ...
Read now
Unlock full access