Search code examples
pythonseleniumwebdriverselenium-chromedriverchromium-embedded

How do I set user data directory in chromium-embedded with chromedriver?


I am trying to use CEF for chrome profile like feature. After some Googling I found that CEF supports a similar capability via CefSettings.cache_path and --cache-path.

But I am unable to figure out how to set this capability via chromedriver.


Solution

  • You can pass cache-path as an argument using chromeOptions.

    Please find below sample code:

    from selenium  import webdriver
    from selenium.webdriver.chrome.options import Options
    chromeOptions = Options()
    
    chromeOptions.add_argument("--cache-path=C:\\CEF\\c_path")
    chromeOptions.binary_location = r"C:\cef_binary_client\Release\cefclient.exe"
    
    driver = webdriver.Chrome(executable_path=r"C:\Driver\chromedriver_220.exe", chrome_options=chromeOptions)
    
    driver.get("https://google.com")
    s = "test" 
    driver.find_element_by_name("q").send_keys(s)