How To Locate Element By Name Locator In Selenium

In the previous post we have seen “locators in Selenium“. In this post, we discuss “How To Locate Element By Name Locator”. Find the below links on How to find elements on a web page using different types of locators.

1. “How To Locate Element By ID Locator
2. “How To Locate Element By Class Name Locator
3. “How To Locate Element By Tag Name Locator
4. “How To Locate Element By Link Text/Partial Link Text Locator
5. “How To Locate Element By CSS Selector Locator
6. “How To Locate Element By XPath Locator

Coming to the actual post “How To Locate Element By Name Locator”.

Name Locator:

We sometimes use Name locator to identify the elements on our webpage. Locating elements using Name is same as locating elements using ID locator.

These are not unique on a page. If there are multiple elements with the same Name locator then the first element on the page is selected. Test may fail, if another element with the same Name locator is present on the web page or added by the developers in the later stages.

Name = Name of the element

  1. Open Mozilla Firefox and navigate to Gmail application.
  2. Open Firebug and inspect the enter your email input box. Take a note of its Name. Follow the below screenshot to do so.
  3. Copy the below mentioned script and execute in your system.

Locate Element By Name Locator

Value to be added in the By.id method:

Script:

How to locate element by name locator

Sumasri is a Sr. Software Test Engineer. Currently working in an MNC. She is a co-founder of Software Testing Material. She has an exclusive experience in the field of Software Testing. She writes here about Manual Testing and Automation Testing.

Leave a Comment

Share via
Copy link
Powered by Social Snap