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
Mobile Test Automation with Appium

You're reading from   Mobile Test Automation with Appium Mobile application testing made easy

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781787280168
Length 256 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Nishant Verma Nishant Verma
Author Profile Icon Nishant Verma
Nishant Verma
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Explicit wait


There are times when the app under test can be slow on certain specific elements, such as page submit, form submit, or somewhere it fetches data from an external system and takes a little more time to load. In that case, using implicit wait to handle the situation will be a flawed approach, given that it has to wait for each and every element for the same specified time.

To handle this situation, we can use explicit wait for such elements. In explicit wait, we tell the web driver instance to wait for a certain condition invoked through ExpectedConditions. So, this wait applies explicitly to the specified element. Explicit wait can be invoked using this code:

WebDriverWait wait = new WebDriverWait(appiumDriver, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("text1")));

In the preceding code, we are creating an instance of WebDriverWait with a maximum waiting time of 10 seconds and then using an ExpectedConditions, which tells the driver to wait till the visibility...

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