0

I have a problem while trying to set up datadriver library with robot framework. I get to error that one of the variables is not found.

CSV File:

${username},${password}
[email protected],adm
[email protected],admin
[email protected],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 

I am getting the below error:

==============================================================================
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
==============================================================================

Can anyone please help me out?

0

1 Answer 1

2

I'm no expert on this library but it looks to me like the delimiter arg is overwritten by the default dialect settings and is remaining as ";" even when you try the override.

It could be worth trying arg dialect=excel as this defaults to ',' delimiter

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

Example:

*** 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}

You may also need *** Test Cases *** column in your csv as I believe it's a required column, something like below:

*** Test Cases ***,${username},${password}
Case1,[email protected],adm
Case2,[email protected],admin
Case3,[email protected],adm
Sign up to request clarification or add additional context in comments.

3 Comments

tried the same. Still getting the same error
@UmangBhatia ah, you may also need *** Test Cases *** column in your csv but when I tried I thought it worked without.. strange, sorry
@UmangBhatia Great :) I made an edit to the answer to include the csv file change

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.