Hi, I am looking for a better way to run my test case with different domain.
Currently, we have a common file that keeps all server, browser, rul information in one place, however, I would like to run the test case with url that is ending with .ca or .ca/fr as well for some of my test case. (Test case steps will be the same, only the url ending part changes (.com or .ca or .ca/fr)
Following code shows how we are able to run it now but there is a problem with this approach, because we are calling test setup in each test case and in test setup it is defined as the Go to Front Page, so the .com page opens up as default when Test Case- “Fill out .ca form Successfully” runs and then it replace the url to .ca.
I am not sure how I should solve this or if there is any other way that Robot Framework already offers.
*** Keyword ***
Go to .com Front Page
[Documentation] Goes to front page
Go To ${FRONT PAGE}
Go to .ca Front Page
[Documentation] Goes to Canada front page ${Canada front page} = Replace String ${FRONT PAGE} .${TOP_LEVEL_DOMAIN}/ .ca/
Go To ${Canada front page}
*** Test Cases ***
Fill out form Successfully
Given User navigate to the .com link
Fill out .ca form Successfully
Given User navigate to the .ca link
Option 2
If you want to test all the sites in the same test suite and have one report
Then the best approach will probably be to use the BuiltIn Set Test Variable to update the necessary variables then you can keep most of your keywords the same like this:
*** Variable ***
${SERVER_ENV} ${NONE}
${TOP_LEVEL_DOMAIN} com
${SERVER} ${SERVER_ENV}.abc.${TOP_LEVEL_DOMAIN}
${BROWSER} Chrome
${REMOTE_URL} ${NONE}
${DESIRED_CAPABILITIES} ${NONE}
${ROOT} https://${SERVER}
${FRONT_PAGE} ${ROOT}/
${SPEED}
*** Keyword ***
Go to Front Page
[Documentation] Goes to front page
# Go To ${FRONT PAGE}
Log ${FRONT PAGE}
*** Test Cases ***
Fill out form Successfully
# Given User navigate to the .com link
Go to Front Page
Fill out .ca form Successfully
# Given User navigate to the .ca link
Set Test Variable $TOP_LEVEL_DOMAIN ca
Set Test Variable $SERVER ${SERVER_ENV}.abc.${TOP_LEVEL_DOMAIN}
Set Test Variable $ROOT https://${SERVER}
Set Test Variable $FRONT_PAGE ${ROOT}/
Go to Front Page