1. Launch Selenium IDE from the Firefox Browser -> Tools Menu
2. Ensure that '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. Turn off the 'Record' option on the Selenium IDE as shown below:
9. Copy the id value from the highlighted HTML code (i.e. but1 in this example)
10. Click on the blank space after the existing commands in the Selenium IDE as shown below:
11. Paste the id value of the highlighted HTML code (i.e. which is copied in the above step 9) into the Target text box of the Selenium IDE as shown below:
12. Click on the 'Find' button beside the Target text box and ensure that the inspected Button on the applications page is getting highlighted in yellow as shown below: (If the inspected Button is getting highlighted in yellow on clicking the 'Find' button on the Selenium IDE, it means that the Selenium is able to find the inspected Button using the 'ID' locator i.e, but1 in this example )
Example of Selenium 'WebDriver' Automation Test Using id=but1 locator:
_driver.findElement(By.id("but1")).click();
Please comment below to feedback or ask questions.
How to Locate UI elements by Name will be explained in the Next Post
1 comment:
Hi Arun.. Is there a reason why ID is preferred over xpath?
Post a Comment