使用Robot Framework

时间:2017-06-28 05:01:47

标签: selenium pycharm robotframework selenium2library robotframework-ide

我需要创建一个循环填充的集合。所以,我需要一个全局集合,我需要使用Robot Framework在For循环中使用该集合变量。

请查看代码

*** Settings ***
Library    Selenium2Library
Library    Collections

*** Keywords ***
Parent Routine
    ${ScoreList} ???
    : For    ${i}     IN RANGE    1    5
    \    Append To List    ${ScoreList}    ${i}
    #\    Some other manipulation


*** Test Cases ***
Sample Test Case
    [Documentation]   Simple test for Collection
    Parent Routine

我提到了http://robotframework.org/robotframework/latest/libraries/Collections.html

请帮助我如何实现这一目标。

1 个答案:

答案 0 :(得分:4)

在您的代码中,您错过了声明,换句话说,您需要使用关键字Create List

创建一个列表

要声明List,您需要使用以下代码

@{ScoreList}=    Create List

完整代码

*** Settings ***
Library    Selenium2Library
Library    Collections

*** Keywords ***
Parent Routine
    @{ScoreList}=    Create List
    : For    ${i}     IN RANGE    1    5
    \    Append To List    ${ScoreList}    ${i}
    #\    Some other manipulation
    :FOR  ${item}  IN  @{ScoreList}
    \    log to console    ${item}


*** Test Cases ***
Sample Test Case
    [Documentation]   Simple test for Collection
    Parent Routine