【问题标题】:attribute and traceback call error running behave属性和回溯调用错误运行行为
【发布时间】:2025-12-14 21:00:02
【问题描述】:

在 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'

【问题讨论】:

    标签: python ubuntu pip python-behave virtual-environment


    【解决方案1】:

    这不是将选项传递给驱动程序的正确方法。

    使用 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)
    

    【讨论】:

      最近更新 更多