Moving elements on the page
As I just mentioned, Selenium, when using the value of the ID attribute, can find elements on a page even if they are moved. Click on the button with the text Random on the Chapter 2 page of the site (you can do this manually), and then run the script that we created earlier. You will see that your test executes successfully.
Finding elements by name
Elements do not necessarily have ID attributes on all of them. Elements can have names that we can use to locate them. In the Target textbox, this would look like name=Element
. Try the following example to see how it works:
- Open Selenium IDE.
- Navigate to http://book.theautomatedtester.co.uk/chapter2 and click on the Firebug icon.
- Find any element that you want to interact with ...
Get Learning Selenium Testing Tools - Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.