ID and NAME
ID and NAME are straightforward location strategies in Selenium. You can use these HTML attributes to identify the elements on the web page.
ID
ID is the attribute of an HTML element. We can use this attribute to identify the object uniquely.
The easiest and quickest method is to locate an element on a web page by its ID. However, the IDs need to be unique and fixed on the page. Without unique IDs, you must opt for other alternate locator techniques.
id=
NAME
NAME is also an attribute of an HTML element. Use the browser developer tools to inspect and look up the HTML source code of the elements.
When the web element’s ID is unavailable, the best alternative is to locate it using its Name attribute.
name=
Examples
The two HTML elements below have the name attributes. You can use the NAME location strategy to identify them on the webpage.
<input type=”text” name=”username”/>
<input type=”password” name=”password”/>