【问题标题】:How to Iterate through all the rows of Excel sheet in Robot Framework如何在机器人框架中遍历 Excel 工作表的所有行
【发布时间】:2021-12-04 01:23:52
【问题描述】:

如何迭代 Excel 工作表的所有行。 ?

下面是我的代码

*** Settings ***
Library           SeleniumLibrary
Library           ExcelLibrary
Library           Collections

*** Variables ***
${path_excel}   C:\\User\\Test.xlsx



*** Test Cases ***
Test1
    Test the ExcelData

*** Keywords ***


Test the ExcelData
    ${my_data_as_list}=    Create List
    #open the Excel  ${path_excel}
    open excel document   filename=${path_excel}  doc_id=Sheet2
    
    FOR   ${i}   IN  20
      ${my_data}=  Read Excel Cell  row_num=${i}  col_num=1
       Log to Console  ${my_data}
      Append To List    ${my_data_as_list}      ${my_data}

    Log to Console   ${my_data_as_list}
    END

它什么也没打印

PS C:\Users\User\PycharmProjects\RobotFramework\Automation> robot .\ExcelExtract.robot
==============================================================================
ExcelExtract
==============================================================================
Test1                                                                 None
[None]
Test1                                                                 | PASS |
------------------------------------------------------------------------------
ExcelExtract                                                          | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Output:  C:\Users\User\PycharmProjects\RobotFramework\Automation\output.xml
Log:     C:\Users\User\PycharmProjects\RobotFramework\Automation\log.html
Report:  C:\Users\User\PycharmProjects\RobotFramework\Automation\report.html

我在网上搜索了所有可能的方法,也没有得到解决方法

【问题讨论】:

    标签: python-3.x excel robotframework


    【解决方案1】:

    请改
    FOR ${i} IN 20

    FOR ${i} IN RANGE 1 20

    【讨论】:

    • 谢谢你,它还有一件事你知道如何获得行数吗??
    • 考虑你想要获取列 A 的行数。 ${col_data}= 读取 Excel 列 col_num=1 ${row_num}= 评估 len(${col_data}) * 抱歉我不知道如何在评论中换行。
    猜你喜欢
    • 1970-01-01
    • 2017-05-02
    • 1970-01-01
    • 1970-01-01
    • 2021-01-05
    • 2018-12-21
    • 2020-03-12
    • 2010-09-09
    • 1970-01-01
    相关资源
    最近更新 更多