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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[馃悰 Bug]: Firefox does not use the profile path when passed via options. Python #11028
Comments
@DollarAkshay, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
Most likely, this issue is a geckodriver problem. But... Selenium Firefox profiles are kind of a pain in general, and we have a lot of code in various languages that worked with the old Firefox extension, not geckodriver. So it's probably a good idea to do some cleanup and verify things work. |
I have fixed this bug, it's actually on the webdriver.py for firefox. If you check line 168 it states if options:
if options.binary:
self.binary = options.binary
if options.profile:
self.profile = options.profile I checked the values and such key(options.profile) is non-existent, upon inspection the values set during the set_preference operation are not going through, thus I added a capability as following caps = {
"os" : "OS X",
"osVersion" : "Monterey",
"buildName" : "firefoxprofile- python",
"sessionName" : "firefoxprofile- python",
"browserName" : "Firefox",
"profile": profilePath,
}
opt.set_capability('bstack:options', caps) Therefore if you overwrite line 168 to 172 with the following: if options:
if options.binary:
self.binary = options.binary
if options.capabilities.get("bstack:options",False):
if options.capabilities["bstack:options"].get("profile",False):
firefox_profile = str(options.capabilities["bstack:options"]["profile"]) the parsing of info actually takes place, that meant for me that values we're under a key related to the setter method name. if options:
if options.binary:
self.binary = options.binary
if options.preferences.get("profile",False):
firefox_profile = str(options.preferences["profile"]) Hope this is helpful in any manner. |
There are 3 types of capabilities: w3c specified capabilities, browser specific capabilities and vendor specific capabilities. The browser options classes are designed to natively manage the first two, and you should not be putting those values inside vendor name-spaced capability dictionaries. Profile should be set top-level, not as a preference, so we need to figure out why this isn't working:
|
Is not working simply because of the handling of the script itself, if you edit the script and print the options object using vars() you get:
There's no profile value in the key since the method stated in the script firefox_profile.py is setting as a "sub-key", you can verify that in the following: # Public Methods
def set_preference(self, key, value):
"""
sets the preference that we want in the profile.
"""
self.default_preferences[key] = value Thus a whole new set_preference method would be need to be written for the sake of such automatic key matching, but in practice it is working as intended, preferences are all a subset which is handled and traversed under that tree node, therefore the issue lies on the usage of the options object on the script webdriver.py itself as stated on my previous comment. Is also stated in that same script that :
Now what happens in the script itself is that no such checkings are made but instead a direct assumption that the value within options is already allocated/assigned under options.profile. This issue has nothing to do with capabilities types or anything of similar fashion, is solely about internal handling of the output of the objects which are then passed/transmited to the geckodriver. |
Ok, dug into this and found the location of the actual issue at least. The problem is that the Instead of just zipping the provided directory, the existing code wants to update things, and whatever it is dong to update them is breaking it. Then this code works as expected:
Let me try deleting a bunch of things and see if everything we want to work still works. :) |
Any update on a fix for this getting merged in? The workaround listed in the original issue (Method 4) is working successfully for me, but I lost over a day to this bug and it would be nice to not have that happen to others. |
I made a PR that deleted a bunch of stuff, but we agreed that we should add deprecation notices instead of deleting things. Issue is being tracked here - #11587 My paid work has picked up, and this is a lower priority item. Not sure ETA. |
I tried doing it with: Example ...
options = Options()
options.page_load_strategy = 'normal'
profile_arg_param = '-profile' ;
profile_arg_value = os.getenv('HOME') + '/snap/firefox/common/.mozilla/firefox/Selenium'
options.add_argument(profile_arg_param)
options.add_argument(profile_arg_value)
browser = webdriver.Firefox(service=Service(GeckoDriverManager().install()), options=options)
... Versions pip3 list | grep -E "selenium|webdriver" ;
selenium 4.10.0
webdriver-manager 3.8.6 |
I've firefox installed with snap, and the above code was the only think that worked for me. After making a blank folder on: |
I forgot about this one. I really need to look at it. |
Firefox has a problem with using saved profile. SeleniumHQ/selenium#11028
Firefox has a problem with using saved profile. SeleniumHQ/selenium#11028
Firefox has a problem with using saved profile. SeleniumHQ/selenium#11028
Firefox has a problem with using saved profile. SeleniumHQ/selenium#11028
Firefox has a problem with using saved profile. SeleniumHQ/selenium#11028
Yes, the idea is to copy the profile to a temp directory, allow the user to modify it with the Profile class if desired, then zip it and send it to the driver. The driver will then unzip it to its own temp directory and use that. Are you having an issue with what should be in the profile, or are you just seeing a different path? |
This issue was closed because we did not receive any additional information after 14 days. |
This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs. |
What happened?
It seems like firefox does not use the profile path when passed via options.
I have tried many different ways to set the profile.
Method 1 (Failing)
Method 2 (Failing)
Method 3 (Failing)
All of these methods result in a temp profile being created somewhere else. This can be verified by looking at the
geckodriver.log
and seeing the profile path in the command.The only way that does seem to work is passing it as an argument
Method 4 (Working)
Setting the profile via the arguments is the only way it seems to use the
profile_path
. This can be verified by looking at thegeckodriver.log
and seeing the profile path in the command and also looking at theprofile_path
folder which gets populated by a bunch of files and folders.How can we reproduce the issue?
Relevant log output
Operating System
Windows 10
Selenium version
Python 4.4.3
What are the browser(s) and version(s) where you see this issue?
Firefox
What are the browser driver(s) and version(s) where you see this issue?
GeckoDriver 0.31.0
Are you using Selenium Grid?
No
The text was updated successfully, but these errors were encountered: