FOR loop with variable

565 views
Skip to first unread message

MarcinR

unread,
Oct 25, 2017, 4:14:51 PM10/25/17
to robotframework-users
Hi all,

I have following code:

Collect Data
      :FOR  ${which}  IN RANGE  1  ${how_much}
      \  Submit Choose
      \  Get Email
      \  Count Nbr
      \  Sleep  10s
      \  Go Back

I log ${how_much} this looks like a number, but when I run I am getting following error:

Converting argument of FOR IN RANGE failed: SyntaxError: unexpected EOF while parsing (<string>, line 0).

When I change my code to:
Collect Data
      :FOR  ${which}  IN RANGE  1  30
      \  Submit Choose
      \  Get Email
      \  Count Nbr
      \  Sleep  10s
      \  Go Back

This works fine.
I was trying to make conversion of ${how_much} but it did not help or I did it wrong. Could you pls. help?

Hélio Guilherme

unread,
Oct 25, 2017, 6:41:11 PM10/25/17
to robotframework-users
It worked fine here. Please check your file for invisible chars like TAB. I did copy and paste your example and there was some strange behavior.

This is my working example:
*** Test Cases ***
test one
    ${how_much}=    Set Variable    ${10}
    : FOR    ${which}    IN RANGE    1    ${how_much}
    \    Log    ${which}

test two
    ${how_much}=    Set Variable    10
    : FOR    ${which}    IN RANGE    1    ${how_much}
    \    Log    ${which}


My Favorite Open Source Projects
awsome-lists gretl meld robotframework wxPython
(sponsored/patrocinado) Recomendo servidores e alojamento Web em:
http://www.proalojamento.com/clientes/aff.php?aff=258

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

MarcinR

unread,
Oct 26, 2017, 4:07:02 AM10/26/17
to robotframework-users
Hi,
thank you for your help.
The issue was slightly different. The issue was with passing the variable from my resource to the Test Suite. And I was logging the ${how_much} on resource level. On test suite it was empty.
To post to this group, send email to robotframe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages