Home > front end >  ChromeDriver not opening new page with chrome_options parameter
ChromeDriver not opening new page with chrome_options parameter

Time:04-27

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?

CodePudding user response:

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)

CodePudding user response:

Use following code :

from selenium import webdriver
from selenium.webdriver.chrome.options import Options as ChromeOptions
#object of ChromeOptions
op = webdriver.ChromeOptions()
#add option
op.add_argument('--enable-extensions')
#pass option to webdriver object
driver = webdriver.Chrome(chrome_options=op)
  • Related