0
votes

I'm new in Robot Framework, and now get stuck while using DataDriver library in my robot script.

My problem: There is a message : "Variable '${username}' not found." while I run the robot script and the test was FAIL.

This is my robot script:

*** Settings ***
Library  DataDriver  file=resources/user_password.csv  encoding=utf_8  dialect=unix
Test Template  Test Credential

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

*** Keywords ***
Test Credential
    [Arguments]     ${username}     ${password}
    Log  ${username}
    Log  ${password}

and this is my CSV file:

*** Test Cases ***, ${username}, ${password}, [Tags], [Documentation]
Valid user, [email protected], pass123, Positive, This is valid user credential
Invalid user, [email protected], pass123, Negative, This user is invalid
Invalid password, [email protected], pass, Negative, This password is invalid
Blank user, ${EMPTY}, pass123, Negative, Blank user
Blank password, [email protected], ${EMPTY}, Negative, Blank password
Blank user and password, ${EMPTY}, ${EMPTY}, Negative, Blank both user and password

Any help would be greatly appreciated. Thanks.

Welly

1

1 Answers

0
votes

I think the problem is in:

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

You're not passing any variables to the keyword as it's shown in the documentation for the DataDriver library: https://github.com/Snooz82/robotframework-datadriver#example-test-suite

A solution would be to pass some values to the keyword:

*** Test Cases ***
Doing Test Credentials for ${username} and ${password}    secret-user    secret-pwd

EDIT:

Another is the format of your csv file. You include spaces after each comma, if I delete them:

*** Test Cases ***,${username},${password},[Tags],[Documentation]
Valid user,[email protected],pass123,Positive,This is valid user credential

I can run it without any problems:

enter image description here

and the report:

enter image description here