Robotframework 数据驱动程序库无法从 CSV 文件中找到变量

Robotframework datadriver library not able to find a variable from CSV file

我在尝试使用机器人框架设置数据驱动程序库时遇到问题。我收到错误消息,未找到其中一个变量。

CSV 文件:

${username},${password}
admin@yourstore.com,adm
adm@yourstore.com,admin
adm1@yourstore.com,adm

DDT2_csv.robot:

*** Settings ***
Library     SeleniumLibrary
Library     DataDriver  ../testdata/TestData.csv    delimiter=,     encoding=utf-8
Resource    ../resources/login_resources.robot
Suite Setup     login_resources.open my browser
Suite Teardown  login_resources.close browsers
Test Template   Invalid Login


*** Test Cases ***
Doing Test Credentials for ${username} and ${password}  Default    UserData

*** Keywords ***
Invalid Login 
    [Arguments]     ${username}     ${password}
    input email  ${username}
    input password  ${password}
    click login button
    error message should be visible 

我收到以下错误:

==============================================================================
DDT2 csv                                                                      
==============================================================================
Doing Test Credentials for ${username} and ${password}                | FAIL |
Variable '${username}' not found.
------------------------------------------------------------------------------
[ WARN ] Multiple test cases with name 'Doing Test Credentials for ${username} and ${password}' executed in test suite 'DDT2 csv'.
Doing Test Credentials for ${username} and ${password}                | FAIL |
Variable '${username}' not found.
------------------------------------------------------------------------------
[ WARN ] Multiple test cases with name 'Doing Test Credentials for ${username} and ${password}' executed in test suite 'DDT2 csv'.
Doing Test Credentials for ${username} and ${password}                | FAIL |
Variable '${username}' not found.
------------------------------------------------------------------------------
DDT2 csv                                                              | FAIL |
3 tests, 0 passed, 3 failed
==============================================================================

谁能帮帮我?

我不是这个库的专家,但在我看来,分隔符 arg 被默认方言设置覆盖,并保留为“;”即使您尝试覆盖。

可能值得尝试 arg dialect=excel,因为它默认为“,”定界符

https://github.com/Snooz82/robotframework-datadriver#file-encoding-and-csv-dialect

示例:

*** Settings ***
Library     SeleniumLibrary
Library     DataDriver  ../testdata/TestData.csv     dialect=excel    encoding=utf-8
Resource    ../resources/login_resources.robot
Suite Setup     login_resources.open my browser
Suite Teardown  login_resources.close browsers
Test Template   Invalid Login

*** Test Cases ***
Doing Test Credentials for ${username} and ${password}  Default    UserData

*** Keywords ***
Invalid Login 
    [Arguments]     ${username}     ${password}
    log to console  ${username}
    log to console  ${password}

您的 csv 中可能还需要 *** Test Cases *** 列,因为我认为这是必填列,如下所示:

*** Test Cases ***,${username},${password}
Case1,admin@yourstore.com,adm
Case2,adm@yourstore.com,admin
Case3,adm1@yourstore.com,adm