selenium webdriver - how to read the csv file in robot framework for data verification -


I want to read a CSV file for data validation. There must be a library or keyword to read the CSV file. I'm using Robot Framework with Ride.

You can easily create your library in Python for reading and writing. Any keyword that you want to create. You can just read and return all the data, or have a keyword that gives the number of rows, or the number of columns or something else.

To read the example keyword in a CSV file:

Save the following definitions in the file named csvLibrary.py Creates a keyword library with a single keyword "Watch CSV File", which passes the path to a CSV file and will return the list as a list of lists. Imported CSV class CSV Library (object): def read_csv_file (auto, filename): '' 'This is a keyword name given "Read the CSV file" This keyword takes an argument, Which is a path one. The Csv file gives a list of these rows, in which each row contains a list of data in each column. '' 'With data file,' RB 'open as CDF file = []: Reader for line in reader = CSV. Reader (csvfile): data. Append (line) return data

Examination Exam:

This exam. Csv will use csvLibrary to open the file, it will be read, and will return results as a list of lists:

  *** settings *** | Library | CsvLibrary.py *** Test Cases *** | Reading CSV File | | $ {Data} = | Read the CSV file. Test.csv | | Logs | $ {Data}  

Comments