For more information on Golem walkthroughs, CLICK HERE.
One of the nice built in features of the Golem automation framework, is the ability to easily setup and configure environments. An environment, is a label that the tests will use to substitute the base URL of the test environment. This is very useful if you are rolling out tests across multiple environments…. such as a QA environment, and then a Release Candidate environment. By simply choosing a dropdown value, we can set which environment the tests will be run against.
You can also stack up tests to run against multiple environments by using a comma to separate each one on the field, like: stage, qa, release_candidate, dev101. Doing so will run the same Test Suite against each environment in turn.

Defining Environments
To define your environments, login to your Golem web server instance and click the “Environments” menu selection.

When the page loads, you’ll add some valid JSON that will be in the format of your environment (as an object) with a key value pair for the “url” and its destination:
{
"test": {
"url": "http://test-url:5000/"
},
"staging": {
"url": "http://staging-url:5000/"
}
}

Setting Up the Tests
Go to a test (or create a new one.)
At the upper middle section of the screen, is a link called “setup.” Click that and some hidden fields will be revealed. These fields are for any pre-work that needs to be performed before the test is rune… like clearing cookies, or configuring the test to read from the environments JSON.


Below I’ve added two Setup rules. The first runs the Golem command “delete_all_cookies” to ensure that each test is run from a clean slate (browser wise.) While Selenium browser instances should not be tainted with cookies, I found in some cases cookies were kept in the browser instances. I added this rule to reinforce he idea that all cookies are killed before the test starts.
The second line below is assigning the built in Golem parameter navigate with value data.env.url. This is our environment object we created earlier on (in JSON.) When the test is run, we will get prompted now to pick our environment… and now the test is hooked into the JSON by means of data.env.url – which will offer environment options we defined in the JSON.

Directly in Code
You can also directly add the setup parameters directly in code. Simply click the “<CODE>” button in the upper right of your test details page.
On the code section you add a setup method like so:
def setup(data):
delete_all_cookies()
navigate(data.env.url)

No responses yet