Simple Jenkins pipeline on AWS (Part 3)

Okay,… The pipeline has already two steps “Build” and “Deploy” running, but the last step “Test” is missing. In this part I will show a simple example with Python, Selenium and Docker (standalone-chrome) for test step.


Install additional packages on AWS EC2

There is a need to install additional packages on AWS EC2 Linux instance (Jenkins).

Create new files and folder (Project/Repository)

You need to create a new directory called “test”. Inside that directory you will create a file “” with following content.

When you are done you have to modify the “Jenkinsfile” and the bash script “”.

Ensure that “” has all needed permission rights. $ chmod +x Commit all changes now and wait that the Jenkins job gets triggered (or trigger manually).

jenkins trigger with parameters

That’s already all… your job should execute all steps. This part is done super fast. πŸ˜‰

Some last words

There is a lot of space for improvements here, but I think you learned already much and had some fun. Some hints now:

  • you can add any other test methods by your self on this step (eq. Performance- and Security tests)
  • Unit tests and Static Code Analysis could executed on build step (before create image)
  • check out AWS ECS Services
  • use a proxy for Jenkins and enable SSL
  • create other pipelines and ECS clusters to enable staging
  • create “Lifecycle policy rules” on ECR
  • use Git Webhook’s to trigger the Jenkins jobs
  • add a post step in your Jenkins pipeline to store metrics and/or inform about build status

Python, Selenium Grid and Docker

With Docker you can quickly and easily install, configure and use Selenium Grid. This tutorial shows the respective steps that you need as a software tester (or Developer). Instead of Python you can also use other languages, which are supported by Selenium​.


Preparation of files

Note: You can opt for a version of docker-compose.yml!

Version: 1

Version: 2

Create environment

Open Browser

Selenium Grid Console

Run Python script

Note: Via browserName ( you can choose the respective browser (firefox or chrome)!

Note: Via docker-compose scale you can add/remove node instances!

Monitor running docker containers with cAdvisor

As a software tester, you have several containers run in your environment. Here is an example how easily and quickly you can monitor your test-environment with cAdvisor.



Note: You can also assign the respective ports!

Run docker containers

Open browser


Create screenshot with Python Selenium Webdriver

The following example show how easy you could make screenshots with Python Selenium Webdriver.



The could be used on different places.

After running the test you should see the folder “/screenshot” with the picture.

JUnit report with Python Webdriver

To create JUnit reports, you just need the python library xmlrunner. This is needed for the integration with build server like Jenkins.



Just replace for example:



On Jenkins add a new “post-build” action and select the Publish JUnit test result report. Add now the string “reports/*.xml” into the “Test report XMLs” field.

DDT with Python Selenium

DDT (Data-driven Testing) with Python Selenium Webdriver is very easy! DDT becomes very useful if you have test cases that contains the same test steps. All values could outsourced into files or databases. This tutorial use CSV files.


  • Python installed
  • selenium andΒ ddt library installed


The folder structure for this tutorial looks like:

Into folder “data” we store the csv files. The packages “library” include a function to read the specific csv files and the package “scenarios” include the test cases. The test suite is on root folder.

Into the “” we add all test cases provided by scenario package.

data folder

The CSV stores the test data that we supplied to the @data decorator of test case.

library package

Just for read the csv and return the values as a list.

scenarios package

Test case withΒ @ddt (for classes), @data and @unpack (for methods) decorators.

  • @data take the argumentsΒ from csv file
  • @unpack unpacks tuples or lists into multiple arguments

The test_search() method accepts the arguments, which will be mapped to the tuple values by ddt.


Python, Selenium and PhantomJS – ignore certificate errors


You are done with your work and push all into Git. The Build-Server starts his work and all test scripts are failing. Short look and it is clear – certificate errors. The next example shows, how to ignore certificate errors on PhantomJS.

Now it should work….

Run your Python Selenium tests headless

This time i show you the headless testing with Selenium WebDriver and PhantomJS. This method can be used for example on continuous integration systems.

Install PhantomJS

Follow the documentation on PhantomJS website or as Mac OS X user simply use Mac Ports.

Create a tiny test script

Just create a instance of PhantomJS WebDriver and run you tests. That is all! πŸ˜‰