The simplest thing we can start with is checking the home page for our website. Lets take this sample page as our test environment.
You can start working with Galen with minimal project structure. Actually you don’t really need anything to perform the simple check of look-and-feel of your website.
Writing specs
Lets write some Galen specs for the home page. First create an empty folder with your test project name and in it create a file named home-page.gspec
We will start with the simplest example. Lets say we want to test that header height is exactly 40 pixels on home page.
IMPORTANT! Indentation in Galen is done with 1 to 8 spaces. Tabs are ignored.
@objects
header id header
= Main section =
header:
height 40px
In our spec above we have defined an object called header and specified the locator for it (by id “header-container”). Then we have defined the simplest check of headers height. Here we basically state that the height of header should be exactly 40 px. If you don’t want to be that strict you can define a range (e.g. from 35 to 45 px)
header:
height 35 to 45px
Configure
In order for galen to be able to communicate with browser we need to get a special driver for it. For Firefox you will need a geckodriver. For Chrome - chromedriver. Download a driver for whatever browser you have and extract it somewhere on your file system. Now you need to define path for that driver in your global config. Simply type galen config --global
in your comand line and it will output something like this:
Created config file: /home/ishubin/.galen.config
Edit that generated config file and add a path to your driver. In the example below we used geckodriver which is used for Firefox browser:
$.webdriver.gecko.driver=/path/to/geckodriver
Launching Galen
IMPORTANT! Galen relies on Selenium so it supports same browsers as Selenium does. If you have problem running Galen in your browser please check the Selenium compatibility. You might have to downgrade your browser or get the latest driver (gecko, chrome etc.) for your browser and define it in your config
In your terminal go to your project folder and type the following command:
galen check home-page.gspec
--url http://samples.galenframework.com/tutorial1/tutorial1.html
--size 640x480
--htmlreport .
The command above will launch Firefox browser and open our test website and perform the check. In the end it will create HTML report in your projects folder in report.html
file.
Comments
We have moved all the discussions to Google Groups. From this moment, if you have problems with your test code or some issues with installation, please ask your questions in https://groups.google.com/forum/#!forum/galen-framework.