在ubuntu实例中工作
installed python 3.7.8
installed pip3
installed virtual environment
behave
behave web driver
allure-behave
selenium
chrome driver
当运行功能文件时,我得到错误
Exception Attribute Error: 'Options' object has no attribute 'arguments'
Traceback (most recent call last):
File "/home/ubuntu/v/bin/behave", line 8, in <module>
sys exit(main())
File "/home/ubuntu/v/lib/python3.8/site-packages/behave/__main__.py", line 183, in main
return run behave(config) File "/home/ubuntu/v/lib/python3.8/site-packages/behave/__main__.py", line 127, in run behave
failed = runner run()
File "/home/ubuntu/v/lib/python3.8/site-packages/behave/runner.py", line 804, in run
return self run with paths()
File "/home/ubuntu/v/lib/python3.8/site-packages/behave/runner.py", line 808, in run with paths
self. load hooks()
File "/home/ubuntu/v/lib/python3.8/site-packages/behave/runner.py", line 784, in load hooks
exec file(hooks path, self hooks)
File "/home/ubuntu/v/lib/python3.8/site-packages/behave/runner_util.py", line 386, in exec file
exec(code, global , locals_)
File "x/features/environment.py", line 2, in <module>
from core environment import behave driver, launch Browser, close Browser
File "/home/ubuntu/core/environment.py", line 19, in <module>
options arguments("--no-sandbox","--headless");
Attribute Error: 'Options' object has no attribute 'arguments'
这不是将选项传递给驱动程序的正确方式。
使用chrome驱动程序的示例:
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_arguments("--no-sandbox")
chrome_options.add_arguments("--headless")
browser = webdriver.Chrome(options=chrome_options)