这是我的代码:
:FOR ${a} IN RANGE 2 ${Row_Count}
\ Run Keyword If '${temp}'== 'True' Click Link xpath=//table[@id='listAllSTR']/tbody/tr[${a}]/td[2]/a and
\ ... Screen validation for Answered ${STR_detail} and
\ ... ELSE Continue For Loop
\ Run Keyword If ${a}>${Row_Count} Exit For Loop**
当 if 条件通过时(即 if '${temp}'== 'True'),我需要单击一个链接,但出现错误提示
Keyword 'Selenium2Library.Click Link' expected 1 argument, got 5.
我不知道该怎么办。
谁能帮帮我?
最佳答案
关于问题。
您在 if 语句中执行了多个关键字,因此它将其他关键字作为第一个关键字的参数。
解决方案
您可以创建自定义关键字并向其添加其他关键字。在您的 if 语句中使用此自定义关键字。请参见下面的示例。
*** Keywords ***
Custom Keyword From If
[Documentation] Keywords documentation.
keyword1
keyword2
*** Test Cases ***
Test Custom Keyword
Run Keyword If '${a}'=='True' Custom Keyword From If
注意:
要执行多个关键字,机器人具有关键字“run keywords”,请参阅文档 link
关于robotframework - 如何在机器人框架的 FOR 循环中使用 if/else 条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53774850/