2

I'm using chromedriver with selenium for python.

I would like to save some settings for an extention, so that the settings come back everytime I load chromedriver with that extention. See below, I would like to save username and password

enter image description here

I'm currently loading extentions as below.

 def __init__(self):
    capa = DesiredCapabilities.CHROME
    capa["pageLoadStrategy"] = "none"

    chrome_options = Options()
    chrome_options.add_extension('/home/simonsays/PycharmProjects/lbc_piscine_spider/chrome_extentions/Cookie-AutoDelete_v2.1.2.crx')
    chrome_options.add_extension('/home/simonsays/PycharmProjects/lbc_piscine_spider/chrome_extentions/Random-User-Agent_v2.1.10.crx')
    chrome_options.add_extension('/home/simonsays/PycharmProjects/lbc_piscine_spider/chrome_extentions/Proxy-Auto-Auth_v2.0.crx')


    self.driver1 = webdriver.Chrome("/var/chromedriver/chromedriver", desired_capabilities=capa,chrome_options=chrome_options)
SimonR
  • 523
  • 1
  • 5
  • 17
  • Do you have to use a blank profile every time the program runs? If not, look into loading the `extension` in another profile/default profile. Read [this](https://stackoverflow.com/questions/31062789/how-to-load-default-profile-in-chrome-using-python-selenium-webdriver) for reference. That way, the setting/extensions saved for that profile should load every time you start the program. – PixelEinstein Feb 21 '18 at 01:26

1 Answers1

2

I resolved my issue with profile approach :

    capa = DesiredCapabilities.CHROME
    capa["pageLoadStrategy"] = "none"

    chrome_options = Options()
    chrome_options.add_argument(
        "user-data-dir=/home/simonsays/PycharmProjects/lbc_piscine_spider/chrome_extentions/profile")
    chrome_options.add_argument("--profile-directory=test")

    self.driver = webdriver.Chrome("/var/chromedriver/chromedriver", desired_capabilities=capa

When the driver opens, I install whatever extensions I want, and they get saved in the profile folder I defined above. I guess you could also copy whatever existing profile you want to use.

SimonR
  • 523
  • 1
  • 5
  • 17