In my test case a new window is opening and i have to perform action on that window then have to come back to orignal window.
driver.switchTo().window("winname")
Using this but dont know the sindow name which is opening after click on a button.
Plese help me how can i manage new window.
Its a good question if we dont know the name of window so how can we switch to another window, For this we can use this code
//Store the current window handle String winHandleBefore = driver.getWindowHandle(); //Switch to new window opened for(String winHandle : driver.getWindowHandles()){ driver.switchTo().window(winHandle); } //Perform the actions on new window //Close the new window, if that window no more required //driver.close(); //Switch back to original browser (first window) //driver.switchTo().window(winHandleBefore);