Selenium - How to import all settings from an existing Firefox profile

前端 未结 1 754
醉梦人生
醉梦人生 2020-12-19 16:46

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 spec

相关标签:
1条回答
  • 2020-12-19 17:27

    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)
      
    0 讨论(0)
提交回复
热议问题