Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What do you mean by locators in selenium?


Asked by Dalton Bowen on Dec 11, 2021 FAQ



What are Locators? Locator is a command that tells Selenium IDE which GUI elements ( say Text Box, Buttons, Check Boxes etc) its needs to operate on. Identification of correct GUI elements is a prerequisite to creating an automation script.
Furthermore,
Selenium has eight different locators to identify a web element on a web page. The following is the list of locators in Selenium Webdriver. Note: All the aforesaid locators return only single elements, however, you can use the .findElements () method to find multiple elements that match the same properties provided using the locators.
Accordingly, In case no such value matches with id, NoSuchElementException will be raised. An element can be defined via multiple attributes, one such is Name. Name locator in Selenium WebDriver can also be used to locate elements like ID locator. They may or may not be unique on a page, having multiple elements.
Keeping this in consideration,
Finding an element with link text is very simple. But make sure, there is only one unique link on the web page. If there are multiple links with the same link text (such as repeated header and footer menu links), in such cases Selenium will perform action on the first matching element with link.
In this manner,
Locators provide a way to access the HTML elements from a web page. In Selenium, we can use locators to perform actions on the text boxes, links, checkboxes and other web elements. They are the basic building blocks of a web page.