Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Selenium Essentials

You're reading from   Selenium Essentials Get to grips with automated web testing with the amazing power of Selenium WebDriver

Arrow left icon
Product type Paperback
Published in Mar 2015
Publisher
ISBN-13 9781784394332
Length 194 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Prashanth Sams Prashanth Sams
Author Profile Icon Prashanth Sams
Prashanth Sams
Arrow right icon
View More author details
Toc

Waits


Wait commands let you put tests on hold or pause for a few seconds or even days. Nowadays, Ajax-based websites are widely in used for their high data-exchanging speed. However, there will be variations in receiving each and every Ajax web service on a fully loaded page. To avoid such delays and to ignore exceptions such as ElementNotVisibleException, it is highly recommended to use waits. To handle such delays on a web page, Selenium WebDriver makes use of both implicit and explicit waits.

Explicit wait

An explicit wait waits for certain conditions to occur. It results in TimeoutError only when the conditions fail to meet their target. In general, the usage of the explicit wait is highly recommended. Here's an example of an explicit wait:

WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.presenceOfElementLocated(By.locatorType("path")));

In the example that follows, WebDriver waits for 20 seconds until the web element is found; if it is not, it will simply...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image