Testing a simple web application using Docker and Galen

Testing a simple web application using Docker and Galen


In today’s video I am going to
Talk about galen and discuss about a spec for testing a simple page. Talk about how to use docker so I don’t
have to install any of the requirements needed by galen
And test against selenium grid using BrowserStack and SauceLabs
So let’s start!!! Galen is a test framework that can be used
for layout and functional testing of web applications, those tests can be run locally against your own
local browsers or against selenium grid as well. I am going to test a simple page created using
vuejs and tensorflowjs, in particular I am going to test that the input fields are next
to each other and that the plus and train buttons are one above the other. Also I am going to test that the text inside
a field has a particular string. For that I am going to use a simplified version
of the “galen sample tests” which demonstrates some of features of the galen framework. For the tests we have the following structure
from bottom to top, A shell file to make it easier to run the
tests without having to remember all the parameters A galen.config file in which I defined that
the default browser is chrome and the path to the chrome driver exe file
The chrome driver dot exe file needed for running tests locally which can be downloaded
from http://chromedriver.chromium.org/ A javascript file with the extension .test.js
inside the tests folder that will call the gspec with the tests to perform,
A file for initializing some options used in most tests, like the breakpoints to be
tested the website root url, etc. Galen Bootstrap which is a simple JavaScript
layout testing framework based on Galen Framework Then inside the specs folder we have a simple
gspec file called tensorflow which first defines the objects that I am going to test, an object
for the x inputs and another one for the y **outputs, one for the plus button one for the
train button and a final one for the prediction text. A section for the fields for training the
model, a loop that will go through each x,y value pairs and check that they are next to
each other and a single check that makes sure that the train button is below the plus button
by 20 pixels And a second section for the fields for predicting
using the model, in which I am only going to test that the “Click on train” text
is present. And finally we have the Galen Extras folder
which is a library for extending the Galen Specs Language with some common expressions First let’s try galen locally, for that
you will need to have it installed, I am going to use npm for that
Also for it to work you have to have java installed as well For running the tests I just need to call
galen and pass the folder in which the js tests are located and the folder for the html
reports as well. We can see that everything was successful Also we can see the report in a web format
by opening the report.html located under the newly created reports folder So now let’s execute our tests but this
time let’s use docker instead. One caveat here is that we don’t have access to the browsers installed in our host. One way to solve this is to use selenium grid. I created a dockerfile for this, first I start
our new image from a clean ubuntu one, declare the workdir as, well, workdir (I know I am
original that way), install openjdk and then nodejs, and finally install galen framework
like we did locally. Define the entry point as galen so that we
can override the parameters from the command line and just to have a default behavior let’s
add a Cmd instruction and just add –help Let’s build the image so that we can instantiate
the container We can test that the galen framework container
is working, by just trying to run the container Which will show the help text as we defined
on the dockerfile file So now let’s try to execute our tests using
our new container, as I mentioned before we don’t have access to any browser on the
host and I didn’t install any on the galen container either. Let’s now use selenium grid for this, first
let’s go to BrowserStack and sign in into your account or sign up for an account if
you don’t have one already, then go to account and then settings and find the Automate section,
copy your username and access key Now let’s enable selenium grid using the
command line and also let’s add the url for browser stack’s selenium grid using
also the username and access key from before For SauceLabs we need the same information
so head to their site and sing in or get a free trial, then click on your username and
then user settings and copy your user name and your Access Key as well by clicking on
show. Now let’s do the same as before and enable
selenium grid, add the url for saucelabs and also the username and access key you just
copied Awesome! Congratulations and thanks for watching! And if you liked the video please hit subscribe

Danny Hutson

Leave a Reply

Your email address will not be published. Required fields are marked *