In the Options class, the add_argument() method is defined as :
def add_argument(self, argument): """Add argument to be used for the browser process.""" if argument is None: raise ValueError() self._arguments.append(argument)
As you can see:
- This method has 2 arguments:
self and argument . - This method does not return anything meaningful (and so returns
None ), and so it does not make sense to save its result (in some variable).
Your code
options = Options.add_argument('-headless')
on the right page, it applies the add_argument() method directly to the Options class , and so it expects these 2 arguments ( self and argument ), but you provide only 1 ( '-headless' ), and so the second argument is not available.
But the add_argument() method is not a class method — it is not intended to be applied to an object . This is evident from the name self for the first argument. When applying a method to an object ( Options class), the self argument is not given - it will be automatically (implicitly) filled with a reference to the object that the method called. Simply
имя_объекта.add_argument('-headless')
perhaps understood as
add_argument(имя_объекта, '-headless')
From this it follows that you need an object of the class Options, which you will directly modify by the add_argument() method and then use it as a parameter instead of
options = Options.add_argument('-headless') browser = webdriver.Firefox(options)
(in your code) use (as you called your options variable) this code:
options = Options() options.add_argument('-headless') browser = webdriver.Firefox(firefox_options=options)