将字符串值添加到列表

时间:2015-09-13 11:47:29

标签: robotframework

我的网页AUT在表格中有大约17行文字。我已经将每个值都添加到临时变量中。现在我想将该字符串添加到列表中。

我收到以下错误:

AttributeError: 'str' object has no attribute 'insert'

例如,我有以下文本行:

Text Line 1
Text Line 2
Text Line 3
...

我想将它们添加到列表中:

@{mylist} = Text Line 1 | Text Line 2 | Text Line 3

这是我的代码,采用Robot Framework格式:

@{list} Create List ${EMPTY}            
${list position}    Set Variable    0           
${number of row}    Get Matching Xpath Count    //table[@class="GridView"]//tr          
${i}    Set Variable    2           
: FOR   ${i}    IN RANGE    2   ${number of row}    
    ${i}    Convert To String   ${i}        
    ${item control} Replace String  ${table profile name default value} rownumber   ${i}
    ${item name}    Get Text    ${item control}     
    Append To List  @{list} ${item name}        

0 个答案:

没有答案