I have done some test suites with Robot framework and Ride including several testcases which requires starting of web browser and user login to website.
Without just copying the testsuites/testcase and hardcode other browser and user login, how can I re-use and re-run existing ones just changing first the used browser, then re-run the same with user2?
Test Cases are something like:
Open Browser - Chrome
#Open Browser - Firefox
Login1
#Login2
Do something....
#For loop already used inside the testcase
FOR ${var} IN IN RANGE 1 10
Exit For Loop If Some condition is true
${var} = Evaluate ${var} + 1
#do something until condition is true
Scroll Element Into View test_element
Set Focus To Element test_element
END
Continue test case....
Keywords:
Open Browser - Chrome
Open Browser https://test.testpage.com/ chrome
......
Open Browser - Firefox
Open Browser https://test.testpage.com/ ff
......
Login1
Wait Until Element Is Visible test_Login_username
Input Text test_Login_username test.id1
Input Password test_Login_password test.password1
Click Button test_Login_LoginBtn
.....
Login2
Wait Until Element Is Visible test_Login_username
Input Text test_Login_username test.id2
Input Password test_Login_password test.password2
Click Button test_Login_LoginBtn
I know that for example I could set the browsers inside for-loop like
*** Variables ***
@{BROWSERS} Chrome ff
And the loop them inside the testcase like
FOR ${Browser} IN @{BROWSERS}
Open Browser https://test.testpage.com/ ${Browser}
END
But the broblem in this is, that you can't use nested for-loops??
It's true you can't have nested loops in RF. It's also true that there's an easy workaround as documented in the user guide:
Your code examples seems a bit messy to me, so I won't go into using these as an example. But in general, I'd: