Showing posts with label tag name. Show all posts
Showing posts with label tag name. Show all posts

Element locators play an important part in interacting with elements in Selenium tests. Let me clarify here that Selenium supports lots of element locators like ID, Name, XPath, CSS Selectors, tagName, linkText, partialLinkText. All the element locators have their own advantages and disadvantages. Let us see what the tagName locator in Selenium, how it works, and when to use it in real-time test automation scenarios.

What is TagName Locator in Selenium?

By.ByTagName is an inner static class inside the By class in Selenium. It represents the By.tagName(String tagName) locator strategy.

TagName locator is a simple and very powerful element locator in Selenium. One can use it to locate an element by HTML tags such as <input>, <a>, <div>, <button>, <h1>, etc. It allows to interact with all the links on a page or loop through rows in a table. Also, you can use it to find elements of a specific tag type, either a single element or a group of them.