简体   繁体   中英

Is there a way to save many values in one variable using a for-Loop in Robot framework?

I need to collect every text witch is in a span element but the loop overwrite the items...

*** Variables ***
${items}    ${EMPTY}

*** Test Cases ***
...

FOR    ${i_i}    IN RANGE    ${Items_Count}
        ${i}=    Evaluate    ${i_i}+1
        ${items[i_i]}=    Get Text    //body[1]/table[1]/tbody[1]/tr/span[${i}]
END

...

it should look like this:

${items} = {txt1 | txt2 | txt3 | ... | textN}

but my result is:

${items} = {last text from span-element}

If you want to have a list of values:

@{list}   Create List
Append To List   ${list}   value_to_append

If you want a Dict-like of values:

&{dictionary}   Create Dictionary
Set To Dictionary   ${dictionary}   key   value

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM