7

Here is my code:

profile = webdriver.FirefoxProfile('C:\\Users\\Administrator\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\kvycjolb.Prdel') driver = webdriver.Firefox(profile) 

Im not getting any error and firefox starts, but it just does not load with this profile: I have tried changing / to // etc.. but no luck.

This also does not work:

from selenium import webdriver from selenium.webdriver.firefox.firefox_profile import FirefoxProfile from selenium.webdriver.firefox.firefox_binary import FirefoxBinary binary = FirefoxBinary("C:\\Program Files\\Mozilla Firefox\\firefox.exe") profile = FirefoxProfile("C:\\Users\\Administrator\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\kvycjolb.Prdel") driver = webdriver.Firefox(firefox_profile=profile, firefox_binary=binary, executable_path="C:\\aprog\\geckodriver.exe") driver.get('https://google.com') 

Im getting error:

C:\aprog>testff Traceback (most recent call last): File "C:\aprog\testff.py", line 7, in <module> driver = webdriver.Firefox(firefox_profile=profile, firefox_binary=binary, e xecutable_path="C:\\aprog\\geckodriver.exe") File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 152, in __init__ keep_alive=True) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l ine 98, in __init__ self.start_session(desired_capabilities, browser_profile) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l ine 188, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l ine 256, in execute self.error_handler.check_response(response) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py" , line 194, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: Unable to find a matchin g set of capabilities 

4 Answers 4

6

I think the official answer is found in documentation.

Presently that is:

# Custom profile folder to keep the minidump files profile = tempfile.mkdtemp(".selenium") print("*** Using profile: {}".format(profile)) # Use the above folder as custom profile opts = Options() opts.add_argument("-profile") opts.add_argument(profile) opts.binary = "/Applications/Firefox.app/Contents/MacOS/firefox" driver = webdriver.Firefox(options=opts, # hard-code the Marionette port so geckodriver can connect service_args=["--marionette-port", "2828"]) 
Sign up to request clarification or add additional context in comments.

2 Comments

I get "Undefined name 'Options'
@MatthewCox, Did you use from selenium.webdriver.firefox.options import Options as in documentation?
4
def setFirefoxDriver(): profilePath = r"PathHere" driverPath = r"pathHere\driver.exe" options = Options() options.add_argument("-profile") options.add_argument(profilePath) dService = Service(driverPath) d = webdriver.Firefox(service=dService, options=options) return d d = setFirefoxProfile() d.get('https://www.amazon.com/) 
  • to know profile paths search in your firefox about:support or about:profiles

  • You can test it loading your own profile and see if cookies are loading, ie: when I go to amazon.com amazon recognizes me.

  • Notice that you can't be using the same profile in 2 different instances, so if you wanna load your profile to test in selenium you shouldn't be using that firefox profile, but another one.

Comments

2

To start Mozilla Firefox with a specific Firefox Profile through Selenium 3.4.3, geckodriver v0.18.0, Mozila Firefox 53.0 and Python 3.6, you need to create a separate Firefox Profile with the Firefox Profile Manager as per the documentation here.

I have created a Firefox Profile by the name debanjan. This profile got stored in this subdirectory:

"C:\Users\AtechM_03\AppData\Roaming\Mozilla\Firefox\Profiles"

The name of the profile (folder) is w8iy627a.debanjan. So while initiating the WebDriver instance we have to pass the absolute path of the Firefox Profile named as w8iy627a.debanjan as follows:

from selenium import webdriver from selenium.webdriver.firefox.firefox_profile import FirefoxProfile from selenium.webdriver.firefox.firefox_binary import FirefoxBinary binary = FirefoxBinary("C:\\Program Files\\Mozilla Firefox\\firefox.exe") profile = FirefoxProfile("C:\\Users\\AtechM_03\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\w8iy627a.debanjan") driver = webdriver.Firefox(firefox_profile=profile, firefox_binary=binary, executable_path="C:\\Utility\\BrowserDrivers\\geckodriver.exe") driver.get('https://google.com') 

Let me know if this answers your question.

5 Comments

I use python27, getting error: Unable to find matching set of capabilities.
Can you update your code and error in the question area for further analysis please? Thanks
Selenium, GeckoDriver, Mozilla Firefox versions please. Thanks
Firefox 54.0.1, Geckodriver 0.18.0win64
Firefox 54.0.1, Geckodriver 0.18.0win64 selenium 3.4.3
0

Always use double backslashes in the path (for Windows paths at least):

profile = webdriver.FirefoxProfile('C:\\Users\\Administrator\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\kvycjolb.Prree') 

In your code, you use both backslashes and forward slashes.

1 Comment

I have repaired that in code, but it did not solve the problem.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.