gpt4 book ai didi

selenium - 使用Robot Framework创建一个空列表并在迭代中推送数据

转载 作者:行者123 更新时间:2023-12-01 09:47:53 30 4
gpt4 key购买 nike

我需要做一个循环填充的集合。因此,我需要一个全局集合,并且需要使用Robot Framework在For Loop中使用该集合变量。

请看一下代码

*** 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

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

最佳答案

在您的代码中,您错过了声明,换句话说,您需要使用关键字Create 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

关于selenium - 使用Robot Framework创建一个空列表并在迭代中推送数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44793988/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com