在调用对象的属性之前,应该先创建对象选项。
有关@property如何工作的更多信息,请参阅此
answer
# create a new object
options = Options()
# calling the property (setter)
options.add_argument('-headless')
使现代化
此外,您的代码示例似乎还有其他问题。
如果您只想提供firefox_选项,则应将其作为关键字参数,因此必须明确提供:
browser = webdriver.Firefox(firefox_options=options)