Skip to content

Instantly share code, notes, and snippets.

@cliffdarling
Created March 21, 2012 14:50
Show Gist options
  • Save cliffdarling/2147818 to your computer and use it in GitHub Desktop.
Save cliffdarling/2147818 to your computer and use it in GitHub Desktop.
Selenium Webdriver expected coindition that can be used to wait for a pop-up or other window to open
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
/**
* Implementation of ExpectedCondition that waits until a second window is opened
* Useful when you need to wait for a pop-up window
* @author cliff.darling
*
*/
public class SecondWindowIsOpened implements ExpectedCondition<Boolean> {
/**
* Default Constructor
*/
public SecondWindowIsOpened(){
}
/**
* {@inheritDoc}
* @see com.google.common.base.Function#apply(java.lang.Object)
*/
public Boolean apply(WebDriver input) {
return input.getWindowHandles().size()>1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment