O'Reilly logo

Selenium Testing Tools Cookbook by Unmesh Gundecha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Synchronizing a test with custom-expected conditions

The Selenium WebDriver also provides a way to build custom-expected conditions along with common conditions using the ExpectedCondition class. This comes in handy when a wait can be handled with a common condition supported by the ExpectedCondition class.

In this recipe, we will explore how to create a custom condition.

How to do it...

We will create a test that will create a wait until an element appears on the page using the custom ExpectedCondition class as follows:

@Test public void testExplicitWait() { //Go to Sample Application WebDriver driver = new FirefoxDriver(); driver.get("http://dl.dropbox.com/u/55228056/AjaxDemo.html"); try { //Get the link for Page 4 and click on it, this will call ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required