This range/series is about test automation. The show the CEO's and managers of this world (in a later moment when all work is done) what exactly the difference is between Tosca and f.e. RobotFrameWork.
The results will be on Youtube just like FlurFunk did with Tosca. ( https://www.youtube.com/channel/UCR5i6k5emJ6hxox-iQcv85Q )
But in some cases I get stuck and I need some help from the community.
This puzzle is about clicking a button until the name changes https://obstaclecourse.tricentis.com/Obstacles/81121
What I got so far is:
*** Settings ***
# https://robotframework-browser.org/
Library Browser
Library String
#Library Tables
#Title is: AGAIN AND AGAIN
*** Variables ***
@{LIST} | CLICK ME | LICK ME |
*** Test Cases ***
Example Test 70310
Browser.OPEN BROWSER https://obstaclecourse.tricentis.com/Obstacles/81121
CLICK xpath=/html/body/section/div/div/h3
CLICK xpath=/html/body/section/div/div/h3
${element}= GET TEXT //*[@id="button"]
FOR ${element} IN @{LIST}
${element}= GET TEXT //*[@id="button"]
CLICK xpath=/html/body/section/div/div/h3
CLICK xpath=/html/body/section/div/div/h3
CLICK //*[@id="button"]
#CONTINUE FOR LOOP IF ${element} != 'ENOUGH'
LOG TO CONSOLE 1
END
FOR ${element} IN @{LIST}
${element}= GET TEXT //*[@id="button"]
CLICK xpath=/html/body/section/div/div/h3
CLICK xpath=/html/body/section/div/div/h3
CLICK //*[@id="button"]
#CONTINUE FOR LOOP IF ${element} != 'ENOUGH'
LOG TO CONSOLE 2
END
FOR ${element} IN @{LIST}
${element}= GET TEXT //*[@id="button"]
CLICK xpath=/html/body/section/div/div/h3
CLICK xpath=/html/body/section/div/div/h3
CLICK //*[@id="button"]
#CONTINUE FOR LOOP IF ${element} != 'ENOUGH'
LOG TO CONSOLE 3
END
FOR ${element} IN @{LIST}
${element}= GET TEXT //*[@id="button"]
CLICK xpath=/html/body/section/div/div/h3
CLICK xpath=/html/body/section/div/div/h3
CLICK //*[@id="button"]
#CONTINUE FOR LOOP IF ${element} != 'ENOUGH'
LOG TO CONSOLE 4
END
FOR ${element} IN @{LIST}
${element}= GET TEXT //*[@id="button"]
CLICK xpath=/html/body/section/div/div/h3
CLICK xpath=/html/body/section/div/div/h3
CLICK //*[@id="button"]
#CONTINUE FOR LOOP IF ${element} != 'ENOUGH'
LOG TO CONSOLE 5
END
FOR ${element} IN @{LIST}
${element}= GET TEXT //*[@id="button"]
CLICK xpath=/html/body/section/div/div/h3
CLICK xpath=/html/body/section/div/div/h3
CLICK //*[@id="button"]
#CONTINUE FOR LOOP IF ${element} != 'ENOUGH'
LOG TO CONSOLE 6
END
FOR ${element} IN @{LIST}
${element}= GET TEXT //*[@id="button"]
CLICK xpath=/html/body/section/div/div/h3
CLICK xpath=/html/body/section/div/div/h3
CLICK //*[@id="button"]
#CONTINUE FOR LOOP IF ${element} != 'ENOUGH'
LOG TO CONSOLE 7
END
FOR ${element} IN @{LIST}
${element}= GET TEXT //*[@id="button"]
CLICK xpath=/html/body/section/div/div/h3
CLICK xpath=/html/body/section/div/div/h3
CLICK //*[@id="button"]
#CONTINUE FOR LOOP IF ${element} != 'ENOUGH'
LOG TO CONSOLE 8
END
FOR ${element} IN @{LIST}
${element}= GET TEXT //*[@id="button"]
CLICK xpath=/html/body/section/div/div/h3
CLICK xpath=/html/body/section/div/div/h3
CLICK //*[@id="button"]
#CONTINUE FOR LOOP IF ${element} != 'ENOUGH'
LOG TO CONSOLE 9
END
FOR ${element} IN @{LIST}
${element}= GET TEXT //*[@id="button"]
CLICK xpath=/html/body/section/div/div/h3
CLICK xpath=/html/body/section/div/div/h3
CLICK //*[@id="button"]
#CONTINUE FOR LOOP IF ${element} != 'ENOUGH'
LOG TO CONSOLE 10
END
Get Text xpath=//body *= You solved this automation problem.
# used resources https://robocorp.com/docs/languages-and-frameworks/robot-framework/for-loops
but I'm pretty sure this is not the full correct way how to do it.
So the question here is: how can I get to the result without re-using the For loop 10 times in the code?
Why is this:
CONTINUE FOR LOOP IF ${element} != 'ENOUGH'
resulting into this: Evaluating expression 'CLICK ME != 'ENOUGH'' failed: SyntaxError: invalid syntax (, line 1)