0

I want to read data using Robot Framework from Google spread sheet. say for example the spreadsheet location is :- https://www.swiggy.com/pop/listing

Can anyone guide me what RF steps are to be written to read the sheet data and store as a list in RF.?

Steps I've Written:

${Excel_List}=  Create List             
Open Excel  ${Excel_Path}               
FOR ${i}    IN RANGE    2   15  
${data} Read Cell Data By Name  External ids    A${i}       
Append To List  ${Excel_List}   ${data}         
Log ${Excel_List}               

enter image description here

Thank You

TG3017
  • 33
  • 2
  • 10

1 Answers1

0

You can try with excelibrary the following two lines

Here, Sheet1 is the worksheet and 1 is the row#

    ${RowVal}=     Get Row Values      Sheet1   1
    @{row_list} =     Convert To List ${RowVal}

OR

You can convert excel file to CSV and then, make use of CSVLibrary and the below keywords from CSVlibrary.

You can install the following library and use one the keywords which converts cvs in to list or convert cvs into list of lists or convert csv into dict.

  1. Download the google sheets to a location, which is accessible
  2. install robotframework-csvlib
  3. Use Built-in Collections

Sample Example

Here, the below line creates a lost of lists, instead of a single list.

${list}=       read csv as list        test.csv
*** Settings ***
Library  CSVLib
Library  Collections

*** Test Cases ***
Test CSV
    ${singlelist}=      Read CSV As Single List     test.csv
    log to console      ${singlelist}

    ${list}=        read csv as list        test.csv
    log to console      ${list}

    ${dict}=        read csv as dictionary      test_dict.csv       Animal      Legs        ,
    log to console      ${dict}

    ${value}=       create list         Legs            Eyes
    ${dictWList}=       read csv as dictionary      test_dict1.csv      Animal      ${value}    ,
    log to console      ${dictWList}
forkdbloke
  • 1,505
  • 2
  • 12
  • 29