[英]How to read Data from Google spread sheet using Robot Framework
I want to read data using Robot Framework from Google spread sheet.我想使用 Google 电子表格中的 Robot Framework 读取数据。 say for example the spreadsheet location is :- https://www.swiggy.com/pop/listing例如,电子表格位置是:- 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.?任何人都可以指导我编写哪些 RF 步骤来读取工作表数据并将其作为列表存储在 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}
Thank You谢谢你
You can try with excelibrary the following two lines您可以使用excelibrary尝试以下两行
Here, Sheet1 is the worksheet and 1 is the row#这里,Sheet1 是工作表,1 是行#
${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.您可以将 excel 文件转换为 CSV,然后使用 CSVLibrary 和 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.您可以安装以下库并使用将 cvs 转换为列表或将 cvs 转换为列表列表或将 csv 转换为 dict 的关键字之一。
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}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.