Creating a Selenium WebDriver script to deal with a popup created by a
web app.
What I'm seeing is that the popup is launched but the script is not
waiting before trying to access the popup. There is a waitForPopup
method on the selenium object but I don't know how to get the selenium
object. I have a WebDriver object and I suspect that the Selenium
object is for a different API.
The way I tried to create a Selenium object doesn't seem right:
WebDriver driver = new InternetExplorerDriver();
WebDriverBackedSelenium selenium = new
WebDriverBackedSelenium(driver,"
http://webguiders.com/");
although it did provide me with an object. When I tried to use the
object, as so:
WebElement link = driver.findElement(By.linkText("guider"));
link.click();
selenium.waitForPopUp("Guider", "60000");
it threw a NoSuchWindowException exception.
Secondly I see suggestions that I should use WebDriverWait, as in ...
WebElement el = (new WebDriverWait(driver, 10)).until(new
ExpectedCondition<WebElement>(){
public WebElement apply(WebDriver driver) {
return driver.findElement(By.something('...'));
}
});
… to wait for an element to appear but Unless I can call ...
driver.switchTo().window("MyWindow");
… won't the WebDriverWait wait for the element to appear on the main
page and not the popup? I need to switchTo() to direct future
commands to the popup but it's the switchTo() that is failing.
Anyone have a WebDriver example of launching and waiting for a popup?