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:
9. What should we do then ? Answer : As we know that we are going to identify and choose the locators according to the priority from the list of locators explained in Post # 20 Different Types of Locators to identify the UI elements , we know that ID locator has the highest priority. If we dont find the ID locator we've to look out for the next priority locator i.e. Name Locator. Now lets go forward and once again view the highlighted HTML code of the selected/inspected Button to find out whether it has 'Name' Locator. Observe that name="but2" is displayed in the highlighted HTML code of the inspected button in this example as shown below:
10. Copy the name value of the highlighted HTML code (i.e. but2 in this example)
11. Click on the blank space after the existing commands in the Selenium IDE as shown below:
14. Hence name=but2 is the locator we've to use in the Selenium WebDriver Automation Test Script for locating the Button with name Button in the above screenshot.
Example of Selenium WebDriver Automation Test Using name=but2 locator:
_driver.findElement(By.name("but2")).click();
Example of Selenium WebDriver Automation Test Using name=but2 locator:
_driver.findElement(By.name("but2")).click();
Please comment below to feedback or ask questions.
How to identify the elements using the 'Link' locator is explained in the next post.
No comments:
Post a Comment