selenium - 如何将多个参数传递给 CumulusCI 测试自动化框架中的测试用例?
问题描述
问题陈述:
无法使用 CumulusCI 命令将多个变量值传递给我的测试用例:
`cci task run robot...
我指的是这个部分来构建我的命令:https ://cumulusci.readthedocs.io/en/latest/tasks.html#id49
如果我必须以与上述相同的方式仅传递一个变量,例如。只是 LocalOrRemote,然后代码工作得很好,所以看起来这与我传递多个变量的方式有关。
我的测试自动化技术栈是 Robot Framework、CumulusCI、Selenium
示例代码:
*** Settings ***
Resource C:/Dev/myproject/robotframework/EnvironmentSetupFile.robot
Suite Setup Run Keywords Suite Setup KW1 AND Suite Setup OS And Browser ${LocalOrRemote} ${Browser}
*** Test Cases ***
Verify whether I am able to set environment and browser
[Tags] LocalEdge
[Documentation] This test should run on the local edge browser
Keyword X
Keyword Y
*** Keywords ***
Suite Setup KW1
do something
Suite Setup OS And Browser
[Arguments] ${LocalOrRemote} ${Browser}
Log Many ${LocalOrRemote} ${Browser}
run keyword if '${LocalOrRemote}'=='Local' Setup Local Browser ${Browser}
... ELSE IF '${LocalOrRemote}'=='Remote' Setup Remote Browser ${Browser}
... ELSE FAIL "Incorrect environment value passed! Please refer the instructions in README for running the test suite"
我用来调用我的测试的命令:
cci task run robot -o suites mypath/MyTestFile.robot -o include LocalEdge -o vars LocalOrRemote:Local,Browser:edge
我面临的问题:
的值${Browser}
不是作为边缘接收的,而是默认为 chrome,这意味着该命令无法将我想要的值传递给 TC。
KEYWORD BuiltIn . Log Many ${LocalOrRemote}, ${Browser}
Documentation:
Logs the given messages as separate entries using the INFO level.
Start / End / Elapsed: 20190522 16:36:53.877 / 20190522 16:36:53.878 / 00:00:00.001
16:36:53.877 INFO Local
16:36:53.877 INFO chrome
解决方案
如何将多个参数传递给 CumulusCI 测试自动化框架中的测试用例?
你这样做的方式是正确的方式:-o vars var1:value1,var2:value2
这是一个非常简单的例子:
*** Test cases ***
Example
Should be equal ${LocalOrRemote} Local
Should be equal ${Browser} edge
将其保存到文件中,然后使用机器人任务运行它,如下所示:
cci task run robot -o vars LocalOrRemote:Local,Browser:edge -o suites example.robot
您将看到变量已正确初始化。如果打开了错误的浏览器,您的某个库必须在${Browser}
您没有意识到的情况下更改变量的值。
推荐阅读
- flutter - Flutter GetX 状态管理
- javascript - 如何使用 jest 在诱惑报告中设置严重性级别
- javascript - 如何在onkeyup中拥有多个功能?
- wordpress - 如何在 wordpress 中删除 WP_head() 函数中的元标题和描述?
- javascript - 我应该买一部 twilio 手机来发送短信吗?
- python - 是否有使用伪 3d 面部标志的面部对齐方法?
- php - 在 save_post_product 钩子中删除它们后,Woocommerce 属性以某种方式再次添加
- excel - vba 将未突出显示的单元格移动到其他工作表
- react-native - 如何使所有选项卡在 react-navigation-v5 中具有相同的标题?
- visual-studio - 从 Firebird 数据库更新模型