Book Image

Learning Selenium Testing Tools - Third Edition

Book Image

Learning Selenium Testing Tools - Third Edition

Overview of this book

Table of Contents (22 chapters)
Learning Selenium Testing Tools Third Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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:

  1. Open Selenium IDE.

  2. Navigate to http://book.theautomatedtester.co.uk/chapter2 and click on the Firebug icon.

  3. Find any element that you want to interact with and, in the Target textbox of Selenium IDE, place the value of its name attribute. For example, use but2, as in the following screenshot, against http://book.theautomatedtester.co.uk/chapter2:

  4. Type the click command into the Command select box.

  5. Play...