-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue with profile.setPreference("browser.link.open_newwindow", 3); #2106
Comments
I also have the same opinion. This could be related with the "new tab" issue. Are you sending CTRL + T to an element in order to open it ? I did use this Java program to reproduce the case sending CTRL + T. And I have the impression that the problem always came when specifying the Firefox profile:
and the correct behavior returned when the profile was not specified:
I think that in that moment I was testing with Firefox 54.0 Then I did use a file system watcher to detect the profiles folder being used and did a copy of two of them: one who worked and one who not. The copy was made before driver.quit() because after that the temporary profile folders are gone. Then I did compare both using meld. The failing case is at the left, the working case is at the right. I attach here the visual comparison split into two screen shoots: this one is the same scrolled down, so you can see the rest: From the ones changed, it seems that browser.link.open_newwindow and browser.link.open_newwindow.restriction could be related because both had a lot of bugs in the past related to opening new tabs. I don't know the details of how Firefox handles the CTRL + T event but it might call at the end the send function that opens a new tab, the one who might been reading those preferences. The documentation says that browser.link.open_newwindow did change the default value to 3 in Firefox 2 and newer. The question would be why it has a value 2 when the profile is not specified. So are the default values only applied when a new profile is used ? |
We're not going to add this feature to legacy Firefox driver. Geckodriver allows to change this preference. |
Hi. I'm getting in touch with this W3C refactoring and the gecko stuff. As long as I have understood the Java class is still FirefoxDriver , it just is been rewritten. How do you note in my test code that I am not using geckodriver ? I see a lot of lines like this in the log:
That means to me that the driver is actually being used, or am I missing something. |
@yucer I've answered to the original report. I can't see how your comment is related to it. Yes, you're using geckodriver, and it does not deny setting "browser.link.open_newwindow" preference to any value.
|
Thanks. It is some how related. Because the original reporter of this issue was also looking a workaround to the issue with the new Tabs: mozilla/geckodriver#786 As long as sending the CONTROL key combinations is not enabled, we could also do something like: driver.executeScript("window.open('http://bings.com','_blank');"); but it can't be done if this preference is 2. It controls the behavior of the where the browser open a new tab. Every time I did try to set it to 3, I got this error:
Nevertheless, now that I see your code, I see the problem. In my case I was setting the preference in the profile, via: FirefoxProfile fp = new FirefoxProfile();
fp.setPreference("browser.link.open_newwindow", 3);
FirefoxOptions options = new FirefoxOptions().setProfile(fp);
FirefoxDriver driver = new FirefoxDriver(options); It seems that property in the profile is now forbidden, but setting them in the options is OK: FirefoxProfile fp = new FirefoxProfile();
// ... set profile preferences
FirefoxOptions options = new FirefoxOptions().setProfile(fp);
options.addPreference("browser.link.open_newwindow", 3);
FirefoxDriver driver = new FirefoxDriver(options); Which is the rule of thumb here? Should all the preferences be specified in the driver options ? Is that valid only when working in geckodriver ? |
I think I found it. It is validated by Preferences class and the keys that are frozen are supposed to be read from one config file, in two sets mutable and frozen, like in this tests I didn't found a place in the java code with that config, but there is a webdriver.json with the values in the javascript firefox driver. Is the same one used? |
Geckodriver provides a new lightweight way to set preferences as shown in my code sample above. You don't have to create a new profile and pass it to the browser (that's time and memory consuming operation). And the new way to set preferences don't impose restrictions, no preference values are "frozen". I'm sorry it's not well documented, but I hope it'll be, in future :) |
OS: windows 7
Selenium Version: 2.52.0
Browser: Firefox
Browser Version: 45.0.1
i need to use something like this to open link in new tab
profile.setPreference("browser.link.open_newwindow", 3);
but getting below error
Exception in thread "main" java.lang.IllegalArgumentException: Preference browser.link.open_newwindow may not be overridden: frozen value=2, requested value=3
I checked the same that above error is because "browser.link.open_newwindow": 2, is frozen in JSON.
Now I just want to know that working with tabs or Opening a new tab for a link in Firefox is still a limitation for selenium , if yes then will it be overcome in upcoming versions ?
The text was updated successfully, but these errors were encountered: