options = FirefoxOptions()
options.add_argument("--headless")
driver = webdriver.Firefox(firefox_options=options, executable_path='/Users/toprak/Desktop/geckodriver')
driver.get("https://twitter.com/login?lang=en")
当我尝试运行我的代码时,我收到此错误:
Warning (from warnings module):
File "/Users/toprak/Desktop/topla.py", line 19
driver = webdriver.Firefox(firefox_options=options, executable_path='/Users/toprak/Desktop/geckodriver')
DeprecationWarning: use options instead of firefox_options
Traceback (most recent call last):
File "/Users/toprak/Desktop/topla.py", line 19, in <module>
driver = webdriver.Firefox(firefox_options=options, executable_path='/Users/toprak/Desktop/geckodriver')
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/firefox/webdriver.py", line 137, in __init__
if options.binary is not None:
AttributeError: 'Options' object has no attribute 'binary'
当我删除关于选项的行并取出“firefox_options=options”时,代码工作正常。我应该怎么做才能解决这个问题?