Selenium provides a range of locators to uniquely identify an element on a web page, for instance by ID, name, link text, etc.
One of the most popular ways to locate an element is by ID. In almost all of web pages, ID is considered to be unique for each element.
Syntax:
driver.findElement(By.id("id"))
Below is the example with more details:
<div class="className">
<input id="eID" name= "eName" type="text" > <label>Name</label>
</div>
<input id="eID" name= "eName" type="text" > <label>Name</label>
</div>
Use the following approach to find element by ID:
driver.findElement(By.id("ch_emailID"))
Post a Comment