I’m looking to setup a webdriver in a script as a headless. I’m able to run it as a non headless way but when i’m creating an instance of the Option() it says me missing 1 required positional argument: ‘value’
chrome_options = Options()
Here’s a replication of the issue I’m having on the project.
from selenium import webdriver from webbrowser import Chrome from ssl import Options from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager class PythonOrg(): def Setup(self): self.chrome_options = Options() self.chrome_options.add_argument("--headless") # self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install())) #not a headless self.driver = webdriver.Chrome(options=chrome_options) def GetLink(self): driver = self.driver driver.get('https://www.python.org') print(driver.title) driver.close() inst = PythonOrg() inst.Setup() inst.GetLink()
Note: I’m new to Python!
Advertisement
Answer
You imported a wrong import.
Instead of
from ssl import Options
It should be
from selenium.webdriver.chrome.options import Options