SUBSCRIBE HERE TO GET POST UPDATES VIA EMAIL :

Delivered by FeedBurner

Selenium - Locating an element by "id" or "identifier" and "Name" element locators

First of all let me introduce you about element locators and why we need to use it. Element locators are useful to identifying GUI elements (button, link, textbox, dropdown, etc..) of HTML page. Selenium requires element locator to identify such elements to perform required action on that specific element. 

There are many different types of element locators available and we will learn all of them one by one. To identifying element's id, you need to install Firebug in your Firefox browser. Generally selenium ID records
element id during recording time. We need to identify it manually when we are editing existing script or inserting new commands manually. You can get latest version of firebug for Firefox from here. Download and install it in your Firefox browser.

Locating an element by element "Id" or "Identifier"





Open Home page of Google. Now turn on your firebug in Firefox browser. Click on "Google Search" button  using firebug inspection tool button.It will show you Element's HTML detail (with blue selection area in above image) with hierarchy as shown in above image.Here you can see that button has id="gbqfba" and name="btnK". Yes, it is "Google Search" button's id and name. Let we use that id with our script so that we can understand it better.

New Test
CommandTargetValue
openhttp://www.google.com
typeid=gbqfqDownload and install selenium IDE step by step
clickid=gbqfba
Look into above example. I have used "id=gbqfba" with "click" command to click on button. In this way we can use "name=btnK" at place of "id=gbqfba". Try it by yourself.

2 comments:

  1. Hey, nice site you have here! Keep up the excellent work!

    Automation

    ReplyDelete
  2. very nice work done here!

    ReplyDelete