Javatpoint Logo
Javatpoint Logo

Selenium IDE- Locating Strategies (By Name)

  • The name locator type will locate the first element with a matching name attribute.
  • For example, name=username.

Let us consider an example on how to use name locator as a target for commands in Selenium IDE.

We will create a login test, so that you could get a better understanding of locating elements through name locator.

  • Launch Firefox browser.
  • Click on the Selenium icon present on the top right corner on your browser.
  • It will launch the default interface of Selenium IDE.
  • Click on the command text box present on the Test Script Editor Box.

Selenium IDE Locating Strategies By Name

Selenium IDE Locating Strategies By Name

For second command to be entered, we need a unique identification element for the Username text box which will help the IDE to identify the target location.

    • Right click on the "Username" text box and select Inspect Element.

Selenium IDE Locating Strategies By Name
    • It will launch a window containing all the specific codes involved in the development of the "Username" text box.

Selenium IDE Locating Strategies By Name
  • Pick element with the matching name attribute that contains the specific name for the "Username" text box.

Selenium IDE Locating Strategies By Name
  • Modify the properties of second command as:
    • Command: click at
    • Target: name=login
    • After execution, this command will click on the Username text box.

Selenium IDE Locating Strategies By Name

We will use the same element for our next command.

  • Modify the properties of third command as:
    • Command: type
    • Target: name=login
    • Value: username
    • After execution, this command will type the username in the Username text box

Selenium IDE Locating Strategies By Name

We will now add a command that will click on the "Password" text box. For this command, we need a unique identification for the "Password" field which will help the IDE to identify the target location.

    • Right click on the "Password" text box and select Inspect Element.

Selenium IDE Locating Strategies By Name
    • It will launch a window containing all the specific codes involved in the development of the "Password" text box.

Selenium IDE Locating Strategies By Name
    • Pick element with the matching name attribute that contains the specific name for the "Password" text box.

Selenium IDE Locating Strategies By Name
  • Modify the properties of fourth command as:
    • Command : click at
    • Target : name=passwd
    • Upon execution this command will click on the Password text box.

Selenium IDE Locating Strategies By Name

We will use the same ID element for our next command which involves typing the password as login credential.

  • Modify the properties of fifth command as:
    • Command : type
    • Target : name=passwd
    • Value : **********(User Login Password)
    • Upon execution this command will type the user password as the login credential.

Selenium IDE Locating Strategies By Name

At last, we need a unique identification element for the Login Submit button which will help the IDE to identify the target location.

    • Right click on the "Go" button and select Inspect Element.

Selenium IDE Locating Strategies By Name
    • It will launch a window containing all the specific codes involved in the development of the "Go" submit button.

Selenium IDE Locating Strategies By Name
    • Pick element with the matching name attribute that contains the specific name for the "Go" submit button.

Selenium IDE Locating Strategies By Name
  • Modify the properties of sixth command as:
    • Command : click at
    • Target : name=proceed
    • After execution, this command will click on the "Go" submit button.

Selenium IDE Locating Strategies By Name
  • Click on the "Run Current Test" button present on the tool bar menu of the IDE. It will execute all of your inserted commands on the browser and gives you an overall summary of the executed test script.
  • The Log pane displays the overall summary of the executed test scripts.

Selenium IDE Locating Strategies By Name

Thus, you can see that we have used name locator as a target for most of our Selenium commands.

Next TopicLocating by XPath





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA