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

Waiting for elements to appear on the page


Web applications now want to appear as though they are desktop applications as more and more people move to hardware, such as tablets or netbooks, which have very small hard drives. This is all done through AJAX to the page.

This means that when we are working with Selenium WebDriver, we need to have it synchronized with what is happening on the page. We do not want to use something like Thread.sleep()because this doesn't make our tests run as quickly as possible. We need to use one of the next two approaches: implicit or explicit waits.

Implicit waits

Selenium WebDriver borrowed the idea of implicit waits from Watir. This means that we can tell Selenium that we would like it to wait until the particular element appears for a certain amount of time. If it cannot find the element on the page, then throws an exception. We should note that implicit waits will be in place for the entire time the browser is open. This means that any search for elements...