简体   繁体   中英

Robot Framework - DataDriver - Select random data from a row within a .csv

I have a spreadsheet with about 3k rows I am trying to select data from (row specific) to enter in data for a form.

Currently my code is repeating the test for all rows in the CSV how can I select data from a random row?

Thanks!

You can easily create your own library in python for reading and writing csv files. Here is a quick example which works with every text style file.

class costomLibrary(object):
    def read_specific_line(self, filename, row):
        '''
        This creates a keyword named "Read Specific Line"
        This keyword takes the filename of the file to read and the row 
        wich is to be read.
        '''
        fp = open(filename)
        for i, line in enumerate(fp):
            if i == row:
                return line

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM