पाया मान लिया जाये कि उम्मीद सिर्फ (पॉपअप के लिए माता-पिता में से एक और एक) ऊपर पॉपिंग तो बस के लिए इंतजार दो खिड़कियां होने जा रहा है दो खिड़कियां आने के लिए, दूसरी विंडो हैंडल ढूंढें और उस पर स्विच करें।
WebElement link = // element that will showModalDialog()
// Click on the link, but don't wait for the document to finish
final JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript(
"var el=arguments[0]; setTimeout(function() { el.click(); }, 100);",
link);
// wait for there to be two windows and choose the one that is
// not the original window
final String parentWindowHandle = driver.getWindowHandle();
new WebDriverWait(driver, 60, 1000)
.until(new Function<WebDriver, Boolean>() {
@Override
public Boolean apply(final WebDriver driver) {
final String[] windowHandles =
driver.getWindowHandles().toArray(new String[0]);
if (windowHandles.length != 2) {
return false;
}
if (windowHandles[0].equals(parentWindowHandle)) {
driver.switchTo().window(windowHandles[1]);
} else {
driver.switchTo().window(windowHandles[0]);
}
return true;
}
});
स्रोत
2014-03-19 17:52:35
चेक कैसे selenium2.0 का उपयोग कर मोडल संवाद या पॉप अप को संभालने के लिए की बेहतर समझ के लिए नीचे दिए गए लिंक http://www.thoughtworks-studios.com/twist/2.3/help/how_do_i_handle_popup_in_selenium2.html – Hemanth