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….

UI testing with DalekJS and PhantomJS on CentOS

With DalekJS you can automate your functional GUI tests very easy. This article describe how to prepare the test environment on CentOS.


First, the necessary packages are installed.

It is also possible to compile PhantomJS itself, but this takes a lot of time.

Prepare test project

Once all is installed without any issues you can start to create the test project.

Create test case

Now it is time for the first Test Case. I have used the example from Dalek website.

Run test

By default DalekJS use PhantomJS as browser. For running the test case simple use dalek command and as argument the test case file (*.js).

Local HAR viewer on Mac OS X

There are several HAR file viewers online but sometimes you need the HAR viewer offline. It is very simple for Mac OS X user to get a local instance running.



The first step is generating HAR file.

Now download the latest and unzip into the user “Sites” folder. Rename the folder and setting up the permissions.


Now open a browser and call URL like: “http://localhost/~<user>/harviewer/“. As last step drag the generated HAR file into the browser. You should see something like this:

HAR viewer result

Full webpage screenshot

For various reasons screenshots for webpages are needed. If automated test scripts fail, documentations must be created or in some other situations. With PhantomJS it is very easy to create these screenshots very fast by command-line. All what is needed a small JavaScript like this.


After save the script you can run it like:

Performance measurement with PhantomJS and confess

PhantomJS and confess make it possible to measure your webapplication performance via command-line.



If your PhantomJS version >= 2.0, phantom.args is deprecated! “TypeError: undefined is not an object” You have to make a quick hack inside the confess.js file.

Run the performance measurement

Note: By default the results go to stdout, but you can pipe into a file!

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! 😉