1

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

2 Answers 2

2

I also observed that if we don't give "dialect=unix" in "Library DataDriver file=resources/logindata2.csv endocing=uft_8", then we get error

Variable '${username}' not found. or Variable '${password}' not found.

Sign up to request clarification or add additional context in comments.

2 Comments

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
Adding dialect=excel worked for me. Current using robotframework-datadriver==0.2.7 and robotframework 3.1.2.
0

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

5 Comments

I have add this 'secret-user secret-pwd' in that line, and the message is the same.
@Welly: you're right. I've updated my answer, try it now. It should work, I've tried that on my side.
@Welly Please don't forget to mark the answer as accepted.
How can I mark the answer as accepted? Fyi, I'm a new stackoverflow user.
Ok, i have read stackoverflow user guide to mark accepted the answer. Thanks.

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.