2

This is my code:

: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**

When the if condition passes (i.e. if '${temp}'== 'True'), I need to click a link, but I'm getting an error saying

Keyword 'Selenium2Library.Click Link' expected 1 argument, got 5.

I don't know what to do.

Can anyone help me out?

1
  • remove ... from 2nd and 3rd line inside for loop those are counted as parameter to the click link keyword Commented Dec 14, 2018 at 7:20

2 Answers 2

6

About the Issue.

You are executing multiple keywords in your if statement so, it is taking other keywords as arguments to first one.

Solution

You can create a custom keyword and add other keywords to it. Use this custom keyword in your if statement. see below example.

*** Keywords ***
Custom Keyword From If
    [Documentation]    Keywords documentation.
    keyword1
    keyword2

*** Test Cases ***
Test Custom Keyword
    Run Keyword If    '${a}'=='True'    Custom Keyword From If

NOTE:

For executing multiple keywords robot has the keyword "run keywords" see the documentation link

Sign up to request clarification or add additional context in comments.

Comments

0

in robot framework ... are used to continue the code on next line as part of previous line in the example you trying after click link keyword you add ... which causing this error remove those and your code will start running.
click link keyword accepts only one parameter as locator in your case it considers following to lines as parameter

:FOR    ${a}    IN RANGE    2    ${Row_Count}

\    Run Keyword If    '${temp}'== 'True'    Click Link    
xpath=//table[@id='listAllSTR']/tbody/tr[${a}]/td[2]/a   
\    Screen validation for Answered    ${STR_detail}   
\    ELSE    Continue For Loop
\    Run Keyword If    ${a}>${Row_Count}   Exit For Loop

edit
new syntax of for loop

FOR    ${a}    IN RANGE    2    ${Row_Count}

    Run Keyword If    '${temp}'== 'True'    Click Link    
xpath=//table[@id='listAllSTR']/tbody/tr[${a}]/td[2]/a   
    Screen validation for Answered    ${STR_detail}   
    ELSE    Continue For Loop
    Run Keyword If    ${a}>${Row_Count}   Exit For Loop
END

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.