Locators
Mastering Locators in Selenium Mastering Locators in Selenium What Are Locators? Locators are the search criteria used to identify web elements on a webpage. Selenium supports eight primary locator strategies: Id Name Class Link Text Partial Link Text Tag Name CSS Selector XPath These strategies are implemented as methods in Selenium’s By class, which provides static methods to define each locator. Using findElement() The findElement() method in Selenium is used to locate a single web element based on the given locator strategy. Example: driver.findElement(By.id("loginButton")).click(); Sample HTML Code with Duplicate Elements <html> <head> <title>DemoSite</title> </head> <body> <div> <input type