I'm running integration tests with Selenium 2.41 over a web application whose console is developed with Apache Wicket 6, and I created an instance of Selenium Firefox web driver:
protected WebDriver seleniumDriver = new FirefoxDriver();
I've a page calling the famous Wicket ModalWindow, in particular if a click a button it shows odal window page to edit or create something. Modal window has two input text fields and a Save button. With Selenium I'm trying to type something into these text fields but I'm only able to access modal window so:
seleniumDriver.findElement(By.xpath("//a[contains(text(),'Create new item')]")).click();
then selenium web driver control stucks on main page, so (following some internet examples) I wrote this code to "switch" control on open modal window:
//Store the current window handle
String parentWindow = seleniumDriver.getWindowHandle();
// switch to configuration modal window
for (String winHandle : seleniumDriver.getWindowHandles()) {
seleniumDriver.switchTo().window(winHandle);
}
WebDriverWait webDriverWaitHalfMinModal = new WebDriverWait(seleniumDriver, 10L);
webDriverWaitHalfMinModal.until(ExpectedConditions.presenceOfElementLocated(By.
xpath("//input[@name='key:textField']")));
// do something in modal window
//Close the new window, if that window no more required
seleniumDriver.close();
//Switch back to original browser (parent window)
seleniumDriver.switchTo().window(parentWindow);
I tried also:
seleniumDriver.switchTo().activeElement();
and
seleniumDriver.switchTo().alert();
But there is no way to make it work, in fact list of window handles has only 1 element, the main page, and not two elements (main and modal page) and there is no way to find text field in the modal window opened with button press. I point out that the rest of my code is working, I'm not able to work only with modal windows. So my question is: How can I manage APACHE WICKET 6 modal windows with Selenium 2.41? Is there a way to switch control from main page to APACHE WICKET 6 modal window?