I am attempting to utilize the Robot Framework Test Template function and have been experiencing a little difficulty.
My current Test consist of opening 5 different websites (declared as variables)
Here is my code:
*** Settings ***
Library Selenium2Library
Library OperatingSystem
Library String
Library Collections
Test Template Open URL
*** Variables ***
${URL1} http://montrealgazette.com/
${URL2} https://www.usatoday.com/
${URL3} http://www.foxnews.com/
${URL4} http://www.cnn.com/
${URL5} https://ca.reuters.com/
*** Test Cases ***
Validate Availability
${URL1}
${URL2}
${URL3}
${URL4}
${URL5}
*** Keywords ***
Open URL
[Arguments] ${URL}
Open Browser $[URL] Chrome
When I run this code, 5 separate blank browser windows are opened.If there is a better way to do this, please let me know. Thanks in advance for the help!
You don't seem to have indented your test case's content, which could perhaps be the problem (after you've fixed the syntax error mentioned in Raj sattam's answer). That's pretty much the only mistake I can see. You'll want to do the same in your keyword's declaration as well.
*** Test Cases ***
Validate Availability
${URL1}
${URL2}
${URL3}
${URL4}
${URL5}
If that still doesn't fix it, instead of using the ** Settings **
section, you may try to declare the test case itself as a templated test case, like this:
*** Settings ***
Library Selenium2Library
Library OperatingSystem
Library String
Library Collections
*** Variables ***
${URL1} http://montrealgazette.com/
${URL2} https://www.usatoday.com/
${URL3} http://www.foxnews.com/
${URL4} http://www.cnn.com/
${URL5} https://ca.reuters.com/
*** Test Cases ***
Validate Availability
[Template] Open URL
${URL1}
${URL2}
${URL3}
${URL4}
${URL5}
*** Keywords ***
Open URL
[Arguments] ${URL}
Open Browser ${URL} Chrome
you can use Execute Javascript Keyword like:
*** Settings ***
Library Selenium2Library
Library OperatingSystem
Library String
Library Collections
Test Template Open URL
*** Variables ***
${URL1} http://montrealgazette.com/
${URL2} https://www.usatoday.com/
${URL3} http://www.foxnews.com/
${URL4} http://www.cnn.com/
${URL5} https://ca.reuters.com/
*** Test Cases ***
Validate Availability
Open URLs In New Tab ${URL1} ${URL2} ${URL3} ${URL4} ${URL5}
*** Keywords ***
Open URLs In New Tab
[Arguments] @{URL}
:FOR ${eachUrl} IN @{URL}
\ Execute Javascript window.open(${eachUrl},"_blank");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With