Home » Selenium IDE- Locating Strategies By Id

Selenium IDE- Locating Strategies By Id

by Online Tutorials Library

Selenium IDE- Locating Strategies (By Id)

  • This type of locator is more explicit and the first element with the matching id attribute is used.
  • It is used only when you know an element’s id attribute.
  • For example, id=login.

Let us consider an example on how to use Id 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 Id 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 Id

Selenium IDE- Locating Strategies By Id

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 Id

    • It will launch a window containing all the specific codes involved in the development of the “Username” text box.

Selenium IDE- Locating Strategies By Id

    • Pick the first element with the matching ID attribute that contains the specific ID for the “Username” text box.

Selenium IDE- Locating Strategies By Id

  • Modify the properties of second command as:
    • Command: click at
    • Target: id=login1
    • Upon execution this command will click on the Username text box.

Selenium IDE- Locating Strategies By Id

We will use the same id element for our next command.

  • Modify the properties of third command as:
    • Command: type
    • Target: id=login1
    • Value: username
    • After execution this command will type the username in the Username text box.

Selenium IDE- Locating Strategies By Id

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 Id

    • It will launch a window containing all the specific codes involved in the development of the “Password” text box.

Selenium IDE- Locating Strategies By Id

    • Pick the first element with the matching ID attribute that contains the specific ID for the “Password” text box.

Selenium IDE- Locating Strategies By Id

  • Modify the properties of fourth command as:
    • Command : click at
    • Target : id=password
    • After execution, this command will click on the Password text box.

Selenium IDE- Locating Strategies By Id

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 : id=password
    • Value : **********(User Login Password)
    • After execution, this command will type the user password as the login credential.

Selenium IDE- Locating Strategies By Id

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 Id

    • It will launch a window containing all the specific codes involved in the development of the “Go” submit button.

Selenium IDE- Locating Strategies By Id

    • Pick the first element with the matching name attribute that contains the specific name for the “Go” submit button.
    • Here, we don’t find any matching id attribute so we have to use the Name locator to locate the “Go” submit button.

Selenium IDE- Locating Strategies By Id

  • Modify the properties of sixth command as:
    • Command : click at
    • Target : name=proceed
    • Upon execution this command will click on the “Go” submit button.

Selenium IDE- Locating Strategies By Id

  • 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 Id

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

Next TopicLocating by Name

You may also like