From the course: Advanced Selenium: Support Classes

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Create your locators

Create your locators - Selenium Tutorial

From the course: Advanced Selenium: Support Classes

Start my 1-month free trial

Create your locators

- [Instructor] Having access to By.XPath and By.CSS locators provides a lot of flexibility for us. But it can still be useful to create our own by classes. These allow us to model the semantics of the application, and this can cut down on the maintenance of CSS and XPath locators. The find by class attribute test finds the buttons and clicks on them a few times to create some messages. And then on line 45, we use the by class name to find all the messages. I'm going to create a by attribute value locator so that I can write a very specific locator in this test. So rather than By.classname, I want to say ByAttributeValue, so I'm going to say new ByAttributeValue, which is going to be our new by locator, and I want to say ByAttributeValue class with the value message. And this will allow us to locate based on any attribute and not just by a class or ID. So to do this I have to create a new by and I'll create that as a new…

Contents