Home > Back-end >  TypeError: EnumMeta.__call__() missing 1 required positional argument: 'value'
TypeError: EnumMeta.__call__() missing 1 required positional argument: 'value'

Time:09-14

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!

CodePudding user response:

You imported a wrong import.
Instead of

from ssl import Options

It should be

from selenium.webdriver.chrome.options import Options

CodePudding user response:

for chrome_options add self.

and use from selenium.webdriver.chrome.options import Options not from ssl import Options

from selenium import webdriver
from webbrowser import Chrome
from selenium.webdriver.chrome.options 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=self.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()
  • Related