I need to open two browser windows at the same time.

For example, when browsing a page in a window and if I click on the link present in that window, that link (URL) should open in a new browser window, not in a new tab.

I tried with multiple driver options and it was calling driver.exe two times and also I've used Ctrl + N key. But it is opening the new browser window without the URL.

When I click on the link in a page, I need that link to open in a new browser window, not in the new tab.

Please help me how to implement this.

  • Why you need selenium with two windows? Selenium is for browser automation. If the app you are automating opens new tab or window, switch to it. If not, you don't have the problem. – P.M May 17 '17 at 13:55
  • Why can't you just grab the link and, if necessary, cookies, of your first session and put them into the second window? – godisalie92 Aug 18 '17 at 15:23

If a new window is a must, I suggest you explore the following options.

Alternative: inject code into your HTML that will force a new window to open - or use a plugin. Both options have code examples listed in this StackOverflow question.

Alternative: set the browser options to always open links in a new window. I think for IE it uses what you've set it to in the browser options themselves. For other browsers, you might want to use the Selenium class to set options for the driver instance - if those even exist.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.