我想将元素保存到列表中,然后运行FOR循环以遍历它们。
我尝试了以下操作:
*** Keywords ***
User Claims Tasks
@{tasks}= Get WebElements ${claim}
FOR ${task} IN @{tasks}
Click Element ${task}
${missing}= Run Keyword And Return Status Element Should Be Visible ${miss}
Run Keyword If '${missing}' == 'True' Click Element ${miss}
${continue}= Run Keyword And Return Status Element Should Be Visible ${cont}
Run Keyword If '${continue}' == 'True' Click Element ${cont}
END
但是,这不起作用。它运行一次,然后出现错误:
20200911 13:40:19.734 : FAIL : IndexError: list index out of range
20200911 13:40:19.737 : INFO : ${relation uid} = ('FAIL', 'IndexError: list index out of range')
20200911 13:40:19.742 : INFO : Relation UID:('FAIL', 'IndexError: list index out of range')
20200911 13:40:19.744 : INFO : Client Information:,
Ending test:
关于如何获得这项工作的任何想法?
答案 0 :(得分:0)
最适合我的解决方案:
*** Keywords ***
User Claims Tasks
${tasks}= Get Element Count ${claim}
FOR ${i} IN RANGE ${tasks}
${present}= Run Keyword And Return Status Element Should Be Visible ${claim}
Run Keyword If '${present}' == 'True' Click Element ${claim}
${missing}= Run Keyword And Return Status Element Should Be Visible ${drm}
Run Keyword If '${missing}' == 'True' Click Element ${drm}
${continue}= Run Keyword And Return Status Element Should Be Visible ${cont}
Run Keyword If '${continue}' == 'True' Click Element ${cont}
END