Ewa*_*Ewa 1 selenium python-3.x python-behave
我开始使用行为和硒来编写自动测试。我想创建名为 url 的参数作为配置参数,并且: - 能够将其设置为默认值 - 能够将其作为参数从命令行传递
我知道我应该能够使用 userdata 来实现这一点,但我无法弄清楚究竟是如何实现的。有人可以帮忙吗?:)
您可以通过 CLI 直接传递您的行为执行需要的任何变量,在我的项目中,我们在 Jenkins CI(Shell 步骤)上使用它,如下所示:
python -m behave -D platform=desktop -D os=linux -D test.environment=$environment -D browser=remote.chrome -D jenkins.job=$JOB_NAME $TAGS -t=~ignore --no-skipped --no-capture --junit --junit-directory junit_reports
Run Code Online (Sandbox Code Playgroud)
在我们的behave.ini:
[behave.userdata]
browser=chrome
platform=desktop ;this should be configurable via behave @tags
os=windows
test.environment=staging
Run Code Online (Sandbox Code Playgroud)
然后在 Python 代码中只需访问数据:
if context.config.userdata['browser'].lower() == ApplicationDriversEnum.SELENIUM_CHROME:
driver = __create_chrome_driver(context)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2001 次 |
| 最近记录: |