Reputation: 521
I am editing my original question, hopefully this shows that I've done a bit more research
I think I figured out one way to do it, however, I'm stuck on something, I figured out that I can use a for loop
to iterate through a list of urls, my question is, for any following steps, such as capture page screenshot
or press key
etc where do I apply those? Do they get nested in the loop also?
I saw another stackoverflow post and it gave me this idea:
*** Variables ***
@{HOMEPAGES} http://example.one http://example.two http://example.three
${BROWSER} ff
*** Test Cases ***
test with several links
:FOR ${homepage} IN @{HOMEPAGES}
\ open browser ${homepage}
\ capture page screenshot ${homepage}
The example above gave me a PASS but I am wondering if I have to put every action inside the for loop
if I want to apply those actions to the @{HOMEPAGES}
array?
Upvotes: 2
Views: 1612
Reputation: 906
There are two more or less standard ways of dealing with your task. You can either use a data-driven test:
*** Settings ***
Test Template Make Screenshots
*** Test Cases *** Web Page
Page one http://example.one
Page two http://example.two
Page three http://example.three
*** Keywords ***
Make Screenshots
[Arguments] ${homepage}
Open Browser ${homepage} ff
Capture Page Screenshot
Or simply use a custom keyword to group the required actions:
*** Variables ***
@{HOMEPAGES} http://example.one http://example.two http://example.three
${BROWSER} ff
*** Test Cases ***
test with several links
:FOR ${homepage} IN @{HOMEPAGES}
\ Make Screenshots ${homepage}
*** Keywords ***
Make Screenshots
[Arguments] ${homepage}
Open Browser ${homepage} ${BROWSER}
Capture Page Screenshot
Personally, I would go with a data-driven test because it's more elegant and easier to scale.
Upvotes: 1