Hello, I have a test where I click on a View Report link which will open the PDF in a Report Viewer in a new browser tab which is the expected behavior. This test works as expected in Chrome and Edge Chromium. However it fails in Firefox due to a setting in Firefox which opens the PDF in a new window instead of a new browser tab. When opening the Firefox run by the automated tests the “Open links in tabs instead of new windows” checkbox is always unticked.
As part of my research, I searched the forums and found other users have had similar issues. I tried the following:
-
Set preferences in Desired Capabilities settings as per Tip for configuring Firefox (geckodriver) to open NEW tabs - this did not work and the console provides this info: Using
new FirefoxOptions()
is preferred toDesiredCapabilities.firefox()
-
Set preferences programmatically as per FirefoxOptions for running Webdriver Tests | Selenium Easy - this throws an error: java.lang.IllegalArgumentException: Preference browser.link.open_newwindow may not be overridden: frozen value=2, requested value=3
This was the code I used:
def setFirefoxPreferencesInProfile() {
FirefoxProfile profile = new FirefoxProfile()
FirefoxOptions options = new FirefoxOptions()
options.setProfile(profile)
options.addPreference("browser.link.open_newwindow", 3)
WebDriver driver = new FirefoxDriver(options)
DriverFactory.changeWebDriver(driver)
}
Note: I tried both with setting a new profile and without. Both do not allow me to set the preference as it shows the same “frozen” error message.
When researching this “frozen” error, it looks like some preferences are frozen and cannot be changed as per java - Selenium cannot set preference for browser.link.open_newwindow - Stack Overflow
Is there another way to set the setting “Open links in tabs instead of new windows” in Firefox?
I am using version 8.6.8. My Firefox version is v120.0.
Thanks!