Search code examples
pythonseleniumgoogle-chromeselenium-chromedriverchrome-options

ChromeDriver not opening new page with chrome_options parameter


I'm trying to use the following code to open a new page using ChromeDriver

import selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument("--headless")
driver = webdriver.Chrome(executable_path=r"path of chromedriver.exe",chrome_options=options)

I still get the "DevTools listening on...." print but no new page is being opened. If however I run:

driver = webdriver.Chrome(executable_path = r"path") 

without the chrome_options parameter, the page opens. Not sure why this is?


Solution

  • chrome_options was deprecated long back.

    DeprecationWarning: use options instead of chrome_options
    

    you have to use an instance of options instead as well as pass the absolute path of the ChromeDriver along with the extension as follows:

    from selenium import webdriver
    
    options = webdriver.ChromeOptions()
    options.add_argument('--ignore-certificate-errors')
    options.add_argument("--headless")
    driver = webdriver.Chrome(executable_path=r"path of chromedriver.exe", options=options)