1

I an executing a simple FOR loop in robot framework. but I am getting the variable not found error.

I am executing below code.

    *** Test Cases ***
ForLoop1
    FOR   ${i}    IN RANGE    1   10
        Log to console  ${i}

    END

I am getting below error in terminal

    (venv) C:\Users\hp\PycharmProjects\RF_Automation\TestCases> robot FOrLoop.robot
c:\users\hp\python38-32\lib\runpy.py:126: RuntimeWarning: 'robot.run' found in sys.modules after import of package 'robot', but prior to execution of 'robot.run'
; this may result in unpredictable behaviour
  warn(RuntimeWarning(msg))
==============================================================================
FOrLoop
==============================================================================
ForLoop1                                                              | FAIL |
Variable '${i}' not found.
------------------------------------------------------------------------------
FOrLoop                                                               | FAIL |
1 critical test, 0 passed, 1 failed
1
  • 1
    When I fix the indentation on the first line, your test works just fine for me with both robot 3.1 and 3.2. Commented May 7, 2020 at 15:35

2 Answers 2

1

I've been struggling with the same error and I found that the keyword "FOR" was written "For" so not recognized as a keyword and thus the "Log to console" statement was trying to print an unknown variable value.

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

Comments

0

Try this syntax instead

: FOR    ${client}    IN    @{clients}
\    Log    ${client}

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.