首页 > 解决方案 > 如何将多个参数传递给 CumulusCI 测试自动化框架中的测试用例?

问题描述

问题陈述:

无法使用 CumulusCI 命令将多个变量值传递给我的测试用例:

`cci task run robot...
  1. 我指的是这个部分来构建我的命令:https ://cumulusci.readthedocs.io/en/latest/tasks.html#id49

  2. 如果我必须以与上述相同的方式仅传递一个变量,例如。只是 LocalOrRemote,然后代码工作得很好,所以看起来这与我传递多个变量的方式有关。

  3. 我的测试自动化技术栈是 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

标签: seleniumrobotframework

解决方案


如何将多个参数传递给 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}您没有意识到的情况下更改变量的值。


推荐阅读