Automated Tests with Golem
Golem is a complete test automation tool for web applications (and soon for API and mobile app tests as well), it comes with a complete web module to build and run tests and a web reports module. It can run tests in parallel, locally and remotely. The Github repo can be found here: https://github.com/lucianopuccio/golem
If you already have installed Python 3.5+ and PIP, you are good to go!, Just run the following command:
pip install golem-framework
To see the detailed installation instructions check http://golem-framework.readthedocs.io/en/latest/installation.html
Create a test directory
First we need to create a test directory, to do so, run the following command:
golem-admin createdirectory tutorial
This will create a new directory 'tutorial', and inside it will have a few files and folders:
- settings.json: contains general configurations that impact all the projects inside this test directory.
- users.json: defines the users that can access the GUI module, for now we’ll use the default (admin/admin)
- The /drivers/ folder should contain the webdriver executables, it’s empty to guarantee that you download the latest versions of the webdriver executables yourself.
- The /projects/ folder, also empty.
We will need to download at least one webdriver executable to run tests locally. For now, we’ll just download the chromedriver in order to use Chrome.
Go to https://sites.google.com/a/chromium.org/chromedriver/ and download the latest version for your current operating system. Put the executable inside the /drivers/ folder and make sure that the “chromedriver_path” in the setting.json is correct.
Start the web module
Run the following command:
This will start the web module by default in the 5000 port, you can access here: http://localhost:5000
And the credentials are admin/admin
Let’s add a project
Let’s create a new project named “wikipedia”
From the project home page, is is possible to add tests, page objects and suites.
It’s is also possible to create a project using the command line:
golem createproject my_project
Adding a new test
We will first add a test:
And the code of an empty test looks like this:
description = ‘’
pages = 
Writing the first test
We add a description to the test: “Perform a search from the initial Wikipedia page and verify that the title of the article is correct”
And we add the following steps:
- Navigate to http://wikipedia.org
- Send keys ‘automation’ to (‘id’, ‘searchInput’)
- Click (‘css’, ‘#search-form button’)
- Verify that the title of the article (‘id’, ‘firstHeading’) is “Automation”
This is the final result:
We run the test and check that it works ok:
Using Page Objects
It’s best to remove the selectors from the test, so we create two page objects:
And inside each we defined the following elements:
search_input = (‘id’, ‘searchInput’)
search_button = (‘css’, ‘#search-form button’)
title = (‘id’, ‘firstHeading’)
You can use the web page builder as well:
Managing test data
Next, we remove the data from the test and put it in the data table below it. This enables us to add more data sets if we need to. If a test has multiple data sets it is going to be executed once per each row in the data table.
And at last, we remove the URL from the test and put in in an environment. We can also put it in the datatable, but since the URL is something in common with the environment and it’s going to be used by all the tests, it’s best to define it outside the test, so every test grabs the URL from a single place. This is useful when we need to run the tests in multiple environments like test, staging and production.
The improved test
The final result is the following:
We run it again to verify it is still working
Running tests in a suite
Next we define a suite. A suite let us group tests with some extra configurations.
This suite will run our test once per each data set, once per each browser and once per each environment. So there will be a total of 6 test executions. We define workers = 3 so it’s executed in parallel reducing total time.
The code of this tutorial is available here: https://github.com/lucianopuccio/golem-tutorial
Read the part 2 of these series here: https://medium.com/@lucianopuccio/running-golem-tests-remotely-with-sauce-labs-8f7ad8105572