How to Switch to the New Browser Window, Which Opens After Click on the Button

How to switch to the new browser window, which opens after click on the button?

You can switch between windows as below:

// Store the current window handle
String winHandleBefore = driver.getWindowHandle();

// Perform the click operation that opens new window

// 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);

// Continue with original browser (first window)

WebDriver switch to browser opened after click on button

The IEDRIVER has problems when there are other sessions open , just close them in the task manager and the problem is solved .

session cookie lost when click made to a link that opens a window with window.open()

How to click A button on the second window of the browser using Selenium with python

By clicking Google Plus button a new window is open.

You have to switch driver to that new window.

So after clicking on the Google Plus button

new_window = driver.window_handles[1]
driver.switch_to_window(new_window)

Now on the new window you should find an element by the following xpath //div[@data-identifier='your_email@gmail.com'] and click it



Related Topics



Leave a reply



Submit