The library provides keywords for Robot Framework to handle CSV files. It enables test case developers to select the cells of a CSV via flexible selector expressions e.g. by specifying the column name instead of column index. In most cases this is more intuitive than selecting cells via column index and it simplifies the work with CSVs especially for CSVs with a large number of columns. Moreover, the selector expressions support usage of regular expressions to select particular rows via a custom search string. The library supports sessions to be able to work with multiple CSV files in parallel.
See the keyword documentation for information about the provided keywords.
Since the library is implemented in Java it can be used together with Jython just by importing the library within the test file. To be able to use it with Python the library has to be imported as remote library (refer to the RobotFrameworkUserGuide for more information about Remote Libraries). Be aware that the Java remote server implementation jrobotremoteserver does not support different library scopes (ROBOT_LIBRARY_SCOPE), hence the scope of the library is always GLOBAL.
*** Settings ***
Library com.github.jep42.roboteasycsv.RobotEasyCsv
java -jar <remote-server-jar> --port 8270*** Settings ***
Library Remote http://localhost:8270/RobotEasyCsv
Assume a CSV file ${TEMPDIR}/userdata.csv with the following content:
firstname;lastname;email;sex
Peter;Pan;[email protected];male
Tinker;Bell;[email protected];female
James;Hook;[email protected];male
A common scenario is to read values from a CSV (e.g. to perform checks on it).
*** Test Cases ***
Check CSV Values
...
Parse Csv From File ${csvSessionId} ${TEMPDIR}/userdata.csv 0
{name}= Get First Csv Value ${csvSessionId} {1}.lastname
Should Be Equal ${name} Pan
{name}= Get First Csv Value ${csvSessionId} {2}.lastname
Should Be Equal ${name} Bell
...
Another common scenario is to change values of a CSV (e.g. to test upload/download scenarios) or to add rows.
*** Test Cases ***
Change CSV Values
...
Parse Csv From File ${csvSessionId} ${TEMPDIR}/userdata.csv 0
Set Csv Values ${csvSessionId} {1}.email [email protected]
Set Csv Values ${csvSessionId} [email=^captain.*$].firstname LittleJames
Add Row ${csvSessionId} Wendy Darling [email protected] female
Save Csv To File ${csvSessionId} ${TEMPDIR}/userdata_updated.csv
...
mvn install on the root folder of the project to build the reactor which consist of two modulesContent type
Image
Digest
Size
111.8 MB
Last updated
over 7 years ago
docker pull jep42/robotremoteserver-easycsvmap