What is Locator | Bondar Academy
Course: Cypress UI Testing with JavaScript
Module: Interaction with Web Elements
Instructor: Artem Bondar
Lesson Summary
Introduction to Locators in Test Automation If you're new to test automation, understanding what a locator is can be crucial. A locator is essentially a combination of attributes that target a specific element or group of elements on a web page. Finding Locators To find locators, you typically inspect the DOM of the web page. Here are some examples: Email Input Field: Right-click and inspect the element. If it has a unique ID , such as input-email-1 , you can use this as your locator. Basic Form Input: Similar to the email field, if this input also has a unique ID , it can be used directly. Inline Form Email Field: If the element lacks unique attributes (e.g., only has a placeholder ), you need to find a unique value nearby. For instance, using the header text of the form can help you build a locator down to the specific input field. Building Complex Locators For scenarios where you need to locate a group of elements, such as users with a specific age in a table, you can combine several attributes to create a locator that returns only the desired rows. This is the essence of locators in test automation: finding unique attributes around the target element and combining them to build effective locators. Next Steps: In the following lesson, we will discuss locator syntax rules and how to use Cypress to locate different web elements on a web page.