I try to use both webdriver
and ChromeDriverManager
at the same time including options but always it returns an error:
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install(), options=options)) TypeError: __init__() got an unexpected keyword argument 'options'
My code is:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
options = webdriver.ChromeOptions()
# options = Options() # I used this line as well, but it did not work.
options.add_argument("start-maximized")
options.add_argument("--headless")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install(), options=options))
driver.get(url)
What should I do?
CodePudding user response:
You have to call it like this:
driver = webdriver.Chrome(
service=Service(
ChromeDriverManager().install()
),
options=options
)