Home > Mobile >  Robot framework: datadriver Library not finding variable from csv file
Robot framework: datadriver Library not finding variable from csv file

Time:09-17

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. If I add this variable to my variables section in my robot file there is no problem to read it. If I do it for the first the error moves on up, to the second variable in the file. When I change the path to the csv file by omitting a character it gives an error not found, and if a proper path is given the values in my csv files do appear in the logging. Reading the csv file does not seem to be the problem, but interpreting it correctly does seem to be. I guess there is a problem with my csv file, but I cannot find, I did try to add single and double quotes.

CSV file:

*** Test Cases ***,${i},${env},${parameter1},${parameter2},${parameter3}
,1,kv,2600787879882,9999000200,${EMPTY}
,2,kv,2600787879882,9999000200,${EMPTY}

Library, keyword and testcase as in robot file:

Library     DataDriver      ../CSVFiles/cardscan2.csv

*** Test Cases ***
Cardscan  with  ${i}   ${env}   ${parameter1}       ${parameter2}        ${parameter3}





*** Keywords ***


 Cardscan
     [Arguments]    ${i}     ${env}     ${parameter1}   ${parameter2}    ${parameter3}
     Create request
     Create expected response
     Send soap message
     Check response

Any suggestions what is going wrong?

CodePudding user response:

There are several issues: need to define a template, replace "," with ";" in the csv and use the test case as a template name for the test cases instead of having it as input variables to a keyword.

Here is the complete working solution:

csv:

*** Test Cases ***;${i};${env};${parameter1};${parameter2};${parameter3}
;1;kv;2600787879882;9999000200;${EMPTY}
;2;kv;2600787879882;9999000200;${EMPTY}

robot:

*** Settings ***
Library     DataDriver   ../CSVFiles/cardscan2.csv
Test Template    Cardscan

*** Test Cases ***
Cardscan With ${i} ${env} ${parameter1} ${parameter2} ${parameter3}

*** Keywords ***
Cardscan
   [Arguments]    ${i}     ${env}     ${parameter1}   ${parameter2}    ${parameter3}
   # ... your other keywords ...

This will result in:

Demo
==============================================================================
Cardscan With 1 kv 2600787879882 9999000200                           | PASS |
-----------------------------------------------------------------------------
Cardscan With 2 kv 2600787879882 9999000200                           | PASS |
------------------------------------------------------------------------------
  • Related