0

ChromeDriver works as expected, when the driver clicks a link that should open a new tab it opens the new tab. This is different with GeckoDriver and InternetExplorerDriver, they always open new window, regardless that when I click these links by myself the new tab is opened as expected.

This is how I click links:

Driver.FindElement(selector).Click();

How to make FF and IE make open new tab when link is clicked when in automated mode? In other words make them behave the same as when I manually click these links.

Yoda
  • 17,363
  • 67
  • 204
  • 344

1 Answers1

1

You can set the default behavior via FirefoxOptions

FirefoxOptions options = new FirefoxOptions();
options.SetPreference("browser.link.open_newwindow", 1);

WebDriver webDriver = new FirefoxDriver(options);
Guy
  • 46,488
  • 10
  • 44
  • 88
  • I've tried 1,2 and 3, but I get: `ArgumentException: Preference browser.link.open_newwindow may not be overridden: frozen value=2, requested value=3` – Yoda Nov 27 '19 at 12:43
  • Solved that, `SetPreference` should be invoked on `FirefoxOptions` object. – Yoda Nov 27 '19 at 12:54
  • @Yoda found a [ticket](https://github.com/SeleniumHQ/selenium/issues/5540), do it with `FirefoxOptions.SetPreference` – Guy Nov 27 '19 at 13:00
  • Yes, that's why I was able to fix that : ), thank you. Now the IE part. – Yoda Nov 27 '19 at 13:07
  • @Yoda It should be the same – Guy Nov 27 '19 at 13:08
  • Unfortunately it isn't, however I'm investigating it right now again. – Yoda Nov 27 '19 at 13:24
  • @Yoda Try `options = InternetExplorerOptions options.AddAdditionalCapability("browser.link.open_newwindow", 1)` – Guy Nov 27 '19 at 13:30
  • That;s the first thing I tried. Checked it, it still opens new windows. – Yoda Nov 27 '19 at 13:37
  • @Yoda I'm not able to find a way to do it, I also encountered several posts regarding actions IE is not allowing, like setting download location. Nothing about this issue specifically, but it makes me wonder. – Guy Nov 27 '19 at 14:02