0

我想使用 Google 电子表格中的 Robot Framework 读取数据。例如,电子表格的位置是:- https://www.swiggy.com/pop/listing

谁能指导我要编写哪些 RF 步骤来读取工作表数据并将其作为列表存储在 RF 中。?

我写的步骤:

${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}               

在此处输入图像描述

谢谢你

4

1 回答 1

0

您可以使用 excelibrary 尝试以下两行

这里,Sheet1 是工作表,1 是行#

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

或者

您可以将 excel 文件转换为 CSV,然后使用 CSVLibrary 和 CSVlibrary 中的以下关键字。

您可以安装以下库并使用将 cvs 转换为列表或将 cvs 转换为列表列表或将 csv 转换为 dict 的关键字之一。

  1. 将 google 表格下载到可以访问的位置
  2. 安装robotframework-csvlib
  3. 使用内置集合

示例示例

在这里,下面的行创建了一个丢失的列表,而不是单个列表。

${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}
于 2019-12-16T13:41:14.363 回答