0

How to change browser instance in Selenium- Java? WebDriver could not locate the elements on the screen after clicking on second webpage

1
  • This or this answers might be useful. Commented Jun 7, 2016 at 14:54

1 Answer 1

0

// First store the current window instance

String winHandleBefore = driver.getWindowHandle();

// After your click operation which opens the new window

// Below code Switches instance to the new window

for(String winHandle : driver.getWindowHandles()){
driver.switchTo().window(winHandle);

}

// If you want to switch back to the original window

driver.switchTo().window(winHandleBefore);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.