6

Why am I doing this:

I need to automate a website that requires client-side SSL certificates. I understand this to be an option which cannot be specified using fp.set_preference(). I am not in control of the server I am connecting to thus I cannot change the security setup.

What have I tried

I have created a separate Firefox profile which has the required 'client-side password protected SSL certificates' set up, select one certificate automaticaly and some manual proxy settings (SOCKS 5). After much googling I have set my code as follows:

from selenium import webdriver url = 'https://www.paininneck.co.uk' fp = webdriver.FirefoxProfile(r"""C:\Users\ <user>\AppData\Local\Mozilla\Firefox\Profiles\<Firefox>""") driver = webdriver.Firefox(fp) driver.get(url) 

The Problem:

The browser does open, however, it is still using the default profile. None of the settings I have changed in the other profile has copied across. The profile specified in my code is still working with selecting it through the Firefox UI.

I am hoping I missed something simple and all this time googling has not been in vain! I am reluctant to change to default settings, however after tweaking the default profile to see if the settings would copy over it is apparent that they don't and Selenium is making a clean copy each time.

Kind regards

Rich

Versions:

Python==3.6.1, Selenium==3.4.3, Firefox==53 gecko driver==v0.16.1 OS==Windows(Its for work dont judge me!) 

1 Answer 1

2

Using Selenium 3.4.x, Python 3.6.1 along with geckodriver v0.16.1 & Mozilla Firefox 53.0, you can use the existing Firefox profile through the following steps:

  1. Locate the Firefox Profile directory on your windows box. For e.g. my Firefox Profile "debanjan" was located at C:\\Users\\AtechM_03\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles by the name w8iy627a.debanjan.
  2. Next, you have to specify the absolute path of the Firefox Profile directory when you initiate the webdriver.
  3. Here is the working code which opens an existing Firefox Profile 'debanjan' on my Windows machine:

    It is to be noted that the current Selenium-Python binding is unstable with geckodriver and looks to be Architecture specific. You can find the github discussion and merge here. So you may additionally need to pass the absolute path of the firefox binary while initializing the webdriver

    from selenium import webdriver from selenium.webdriver.firefox.firefox_binary import FirefoxBinary profile = webdriver.FirefoxProfile('C:\\Users\\AtechM_03\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\w8iy627a.debanjan') binary = FirefoxBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe') driver = webdriver.Firefox(firefox_profile=profile, firefox_binary=binary, executable_path="C:\\Utility\\BrowserDrivers\\geckodriver.exe") url = 'https://www.paininneck.co.uk' driver.get(url) 
Sign up to request clarification or add additional context in comments.

1 Comment

I changed the directory of the profile to point to the version in Roaming, I had previously used the version in Local. I don't know what the difference between the two is but it has fixed the problem. Thank you for your help.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.