My scenario is:
- main window-> do some activity.
- click on Save button-> Confirmation pop up open with OK and CANCEL button.
- Click on OK button on confirmation popup ->another success pop up open with OK button.
- click on OK button on success pop up.
- switch to main window.
Above PopUp is HTML pop ups. How do i handle above scenario in selenium?. I am new on selenium. Please help me.I am stuck on above point.
Code
String ParentWindow = driver.getWindowHandle(); //switching from parent to pop up window
for (String Child_Window : driver.getWindowHandles()) {
driver.switchTo().window(Child_Window);
WebDriverWait wait = new WebDriverWait(driver, 30);// 1 minute
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("test")));
driver.findElement(By.xpath("//input[@value='test']")).click();
}
driver.switchTo().window(ParentWindow);
HTML
<div>
<div class="msgBoxContainer">
<div id="msgBox1473308035532Image" class="msgBoxImage">
<img src="styles/images/confirm.png">
</div>
<div id="msgBox1473308035532Content" class="msgBoxContent">
<p>
<span>Saveでよろしいですか??</span>
</p>
</div>
</div>
<div id="msgBox1473308035532Buttons" class="msgBoxButtons">
<input id="msgBox1473308035532FirstButton" class="msgButton" type="button" value="はい" name="はい">
<input class="msgButton" type="button" value="いいえ" name="いいえ">
</div>
</div>
</div>
// When click on OK button of first popup the respective div is destroy and new div getting generated for Second pop up
<div id="msgBox1473308225709" class="msgBox" style="background-image: url("styles/images/msgBoxBackGround.png"); opacity: 1; top: 52.5px; left: 566.5px;">
<div class="msgBoxTitle">Information</div>
<div>
<div class="msgBoxContainer">
<div id="msgBox1473308225709Image" class="msgBoxImage">
<img src="styles/images/info.png">
</div>
<div id="msgBox1473308225709Content" class="msgBoxContent">
<p>
<span>登録完了</span>
</p>
</div>
</div>
<div id="msgBox1473308225709Buttons" class="msgBoxButtons">
<input id="msgBox1473308225709FirstButton" class="msgButton" type="button" value="はい" name="はい">
</div>
</div>
</div>
