在Robot Framework中测试来自两个不同来源的数据

时间:2019-12-16 07:56:40

标签: python selenium robotframework

我想使用机器人框架同时测试和验证来自两个不同来源的数据。 Source-1 Source-2

我被困住了,我不知道如何继续。我到目前为止已经提出了代码

    ${row_count}=  get element count  ${basic_info_table_row}
    Should Be Equal As Integers  ${row_count}  12
    ${column_count}=  get element count  ${basic_info_table_column}
    Should Be Equal As Integers  ${column_count}  2

    ${row_list}=  BuiltIn.Create Dictionary
    FOR  ${row}  IN RANGE  ${row_count}+1
       ${row_text}  get text  ${basic_info_table_row}
       log to console  ${row_text}
    END

现在发生的事情是,它仅占用第一行,并再次记录第一行。 Report

1 个答案:

答案 0 :(得分:0)

您使用FOR ${row} IN RANGE ${row_count}+1进行了循环,但在循环内 的任何地方都没有使用${row}。该块${row_text}${basic_info_table_row}中的两个值每次都保持相同。

如果您想使用$row作为索引,则将其与${basic_info_table_row}一起使用。或在xpath中使用$row${basic_info_table_row}使用的标识符(或仅使用${basic_info_table})-不在您的问题之内。

有关如何使用标识符中的索引的信息,请参见this answer。请注意xpath中使用的tr[${row}]

${row_text}=   Get Text    xpath=/html[1]/body[1]/div[5]/section[1]/div[6]/table[1]/tbody[1]/tr[${row}]/td[6]
相关问题