如何在列表中单击逐个元素的元素:
id=${NameFirst.replace(" ", ""}_${NameLast.replace(" ", "")}
*Keywords*
| Get all first and last names
| | ${Name} | Query Master Database
| | ... |
| | [Return] | ${Name[0][0]} | ${Name[0][1]}
*Test Case*
| Click element by element
| | :FOR | ${NameElement} | IN | @{NameElementList}
| | ${NameFirst} | ${NameLast}= | Get all first and last names
| | set suite variable | ${NameFirst}
| | set suite variable | ${NameLast}
| | Click Element | id=${NameFirst.replace(" ", ""}_${NameLast.replace(" ", "")}
当我运行测试用例时,它只点击第一个元素
INFO ${Name} = [['AAA', 'BBB'], ['CCC', 'DDD']]
INFO ${NameFirst} = AAA
INFO ${NameLast} = BBB
答案 0 :(得分:0)
首先,您的循环似乎没有正确格式化。循环体需要额外的压痕。以下示例说明:
*Test Case*
| Click element by element
| | :FOR | ${NameElement} | IN | @{NameElementList}
| | | ${NameFirst} | ${NameLast}= | Get all first and last names
| | | set suite variable | ${NameFirst}
| | | set suite variable | ${NameLast}
| | | Click Element | id=${NameFirst.replace(" ", ""}_${NameLast.replace(" ", "")}
这里属于forloop的线需要间隔开,留下一个单元。 PFA