微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

属性和回溯调用错误运行行为

如何解决属性和回溯调用错误运行行为

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。