Google+

27. Finding locators for UI elements using the Selenium IDE's recording feature



There are cases where you have found the locators for the UI elements using the FireBug and Firepath tools but while running the test, the Selenium is not able to identify the UI elements using the given locators. So what is the solution for these kind of problems?

You have to use Selenium IDE's recording feature for recording the scenario and view the proper locator value so that the Selenium can run the tests without any issues. How to use Selenium IDE's recording feature to find the locators of the UI element will be explained in the below steps:

Task - Lets find out the locators for identifying the 'Chocolate' button at http://book.theautomatedtester.co.uk/chapter2


1. Launch Selenium IDE from the Firefox Browser -> Tools Menu
2. Ensure that the record option on the Selenium IDE is turned on by default
3. Open http://book.theautomatedtester.co.uk in the Firefox Browser
4. Click on the 'Chapter2' link as shown below:



5. In Chapter 2 page, click on the 'Chocolate' button as shown below:


6. Now find out the steps that got recorded in the Selenium IDE using the recording feature while we are performing the above operations on the http://book.theautomatedtester.co.uk application.

7. Observe that the following steps were recorded in the selenium IDE:


8. Identify the step that is related to the 'Chocolate' button as shown below:


9. View the values listed down in the Target drop down box after selecting the above identified step as shown below. 


Each of the values listed down in the above Target drop down are nothing but the locators used by the Selenium IDE for identifying the UI element i.e. Chocolate button in this example. You can copy the locators displayed in the Target drop down field and use them any where required by the Selenium Tools i.e. Selenium RC and Selenium WebDriver.

10. Select the values displayed in the Target Dropdown field one by one and click on 'Find' Button beside it. Verify that the 'chocolate' button on the application is getting highlighted in yellow color when you click on 'Find' button. If the 'chocolate' button is getting highlighted on clicking 'Find' button, it means that we are able to locate the UI element using the selected value in the Target Dropdown field. If all the values displayed in the Target dropdown field are able to locate the 'chocolate' button, then you can choose according the Priority of locators explained in previous posts.

We came to a point where learning Core Java is must else we wont be able to understand the upcoming posts on Selenium 1, Selenium 2 and Selenium Grid etc which requires Core Java knowledge. So I've decided to write posts on Java.

The next post will give an introduction on how I am going to explain the Java Concepts that are required by Selenium






Please comment below to feedback or ask questions.

Usage of Java in Selenium will be explained in next post.


12 comments:

man said...

Hi Arun,
whether we need to go through http://www.seleniumone-by-arun.blogspot.in/ before http://seleniumtwo-by-arun.blogspot.in
Bot are having same commands like Ischecked(),Isselected().Can we skip selenium RC.

Arun Motoori said...

@man - Yes you can skip Selenium RC.

man said...

Hi Arun,

You mentioned prerequiste for "Create a JUnit Selenium WebDriver Test using Selenium IDE" is Post# 5 Start the Selenium Standalone Server. SO I have confusion over here.Please clarify.

Arun Motoori said...

@man - I am unable to find the blog post you mentioned. Please mention the post number of the blog in which I have mentioned that.

man said...

Please verify the prerequiste 2 in below link
http://seleniumtwo-by-arun.blogspot.in/2013/05/6-create-junit-selenium-webdriver-test.html

man said...

Please verify the prerequiste 2 in below link
http://seleniumtwo-by-arun.blogspot.in/2013/05/6-create-junit-selenium-webdriver-test.html

Unknown said...

That is enough to understand selenium IDE whatever you mention in your blog(12-27). shall we start web driver now.

Arun Motoori said...

@Rohan - If you already know Java, you can jump into WebDriver. Else I suggest you to learn Java from the blog first.

Unknown said...

i kn java is must for web driver but im asking about selenium IDE is enough whatever you mention in blog .
i read IDE from 12-27 that is enough?

Arun Motoori said...

@Rohan - Yes IDE posts mentioned in my blog are enough.

Ranjan said...

I am receiving only name=verifybutton instead of xpath which clicking on choclate button. Is it fine?

Arun Motoori said...

@Ranjan - Dont worry much about what Selenium IDE is returning like name=verifybutton etc. This post is just to explain how different locators can be used to identify the UI elements. Going forward, we will be using Selenium WebDriver to write Selenium Automation scripts. Its worth learning Selenium WebDriver instead of Selenium IDE.