Reputation: 55
How can I run IF statement from bottom in romot framework?
(while i!=500:/ i = i + 1)
How can I execute python code as I tried to do on the bottom of my code?
*** Settings ***
Library SeleniumLibrary
*** Variables ***
${Browser} Chrome
${URL} https://safeweb.aec.cz/level12.php
*** Test Cases ***
MYbot prihlas_kopiruj_stlac
Open Browser ${URL} ${Browser}
Input Text name:login name
Input Text name:password pwd
Click Button submit
go to ${URL}
while i!=500:
${get_text}= Get Text //*[@id="cid"]
Input Text name:captcha ${get_text}
Click Button ok
i = i + 1
I tried to do it this way but it's complaining
FOR loop contains no keywords
I just never used this way of coding loops (and I'm also supposed that this module is not using classical loops like in others programming languages).
: FOR ${i} IN RANGE 1 500
${get_text}= Get Text //*[@id="cid"]
Input Text name:captcha ${get_text}
Click Button ok
Upvotes: 0
Views: 1172
Reputation: 7271
I do not know which version of Robot Framework you use, but I suggest upgrading to 3.1 as they have cleaned up the for loop syntax there a little bit.
While the one you have mentioned in your answer is still supported, a much nicer syntax has been added:
FOR ${i} IN RANGE 1 500
${get_text}= Get Text //*[@id="cid"]
Input Text name:captcha ${get_text}
Click Button ok
END
You do not need the :
and all those \
, and the end of the loop body is marked explicitly as well.
Upvotes: 2
Reputation: 55
I just found out solution
: FOR ${i} IN RANGE 1 500
\ ${get_text}= Get Text //*[@id="cid"]
\ Input Text name:captcha ${get_text}
\ Click Button ok
this way it's working
Upvotes: 3