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:
7. Observe that the following steps were recorded in the selenium IDE:
9. View the values listed down in the Target drop down box after selecting the above identified step as shown below.
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.