Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 286 characters in body
Source Link
Ajinkya
  • 22.7k
  • 33
  • 113
  • 164

driver.switchTo().window() will work only if new window is opened by any action in existing window. If you are using different drivers to open different windows then it wont work.
In such case you need to choose appropriate instance of driver to control the new window.

Suppose you have instance of webdriver

// Window 1 WebDriver chrome = new ChromeDriver() // Window 2 WebDriver firefox = new FirefoxDriver() 

Now use chrome whenever you want to interact with Window 1 and use firefox to interact with Window 2.

driver.switchTo().window() will work only if new window is opened by any action in existing window. If you are using different drivers to open different windows then it wont work.
In such case you need to choose appropriate instance of driver to control the new window.

driver.switchTo().window() will work only if new window is opened by any action in existing window. If you are using different drivers to open different windows then it wont work.
In such case you need to choose appropriate instance of driver to control the new window.

Suppose you have instance of webdriver

// Window 1 WebDriver chrome = new ChromeDriver() // Window 2 WebDriver firefox = new FirefoxDriver() 

Now use chrome whenever you want to interact with Window 1 and use firefox to interact with Window 2.

Source Link
Ajinkya
  • 22.7k
  • 33
  • 113
  • 164

driver.switchTo().window() will work only if new window is opened by any action in existing window. If you are using different drivers to open different windows then it wont work.
In such case you need to choose appropriate instance of driver to control the new window.