I am facing issue while switching between two windows using selenium web driver.
I am working on automating the web pages using selenium webdriver.
In the parent window I need to click on a button and it will open a new window.I need to fill some data on the new window and click on the save button.After clicking on the save button,this window will be closed automatically and redirected to the parent window and the parent window will be refreshed to dispaly the data that was added on the new window.But during the redirection it is failing to switch back to the parent window and throwing the secutiry violation error.
I am using the below code to switch between windows
public void switchwindow(){
try {
String winHandleBefore = getDriver().getWindowHandle();
for(String winHandle : getDriver().getWindowHandles()){
getDriver().switchTo().window(winHandle);
}
}catch(Exception e){
}
}
Please help me on this issue.
driver.switchTo().defaultContent();driver.switchTo().defaultContent();Curious to know how this code will relate to this question? More over this will be used for frame switch handling.