Selenium Testing on Kentico Sites

Written by Ilesh Mistry
September 24th 2014

6 minute read

There are many web browser automation testing tools out there, but here at MMT Digital we have been using Selenium - Web Browser Automation as one of the testing tools.

What is Selenium?

No point in me trying to explain this one differently to what the website has written, so I have taken this snippet from the Selenium HQ website...

Selenium automates browsers. That's it! What you do with that power is entirely up to you. Primarily, it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) also be automated as well.

Sounds awesome, where can you use it?

You can use Selenium on any online web browser applications, websites etc... to test specific functionalities. Anything you can run on a web browser should work with this. For us we have in particular been using Selenium to test our Kentico websites.

We have Selenium to test a range of elements on our Kentico sites. From something simple, like checking whether there is an element on a page, compare to something more complex, like completing a registration form and the process to the thank you page.

As mentioned above, you have the power to test as little or as much as you want.

Where can I get it?

You need to have Firefox running for this. It is the Selenium IDE, which you need to download. The current version is 2.7.0. It is best to download this in Firefox.

After downloading, run the installer and it will install the necessary components including the Selenium IDE.

This should then add an icon to your Firefox toolbar.

Selenium IDE

The Selenium IDE is an Integrated Development Environment for Selenium scripts. It works really well and all levels of users can use this. You don't have to be a developer to use this and create test scripts.

Selenium works in the following way, where you have one or many Test Suites. Within the Test Suites you can add one or many Test Cases. The Test Cases are the individual Selenium Tests you wish to perform within the particular Test Suite.

Hopefully I haven't lost you here, stay with me.

So imagine you have Test Cases in mind, but how would you use the Selenium IDE to add them in?

Selenium IDE Test Case Example

Let me use a simple example to illustrate how Selenium IDE could be used to test something.

Ok the example I am going to use is that imagine you wish to test whether a simple form shows an error message if a mandatory field has not been filled in.

To do this, we first need to create the Test Suite. So you can do this using the Menu options, using File --> New Test Suite and provide it a name and location to save it. Once the Test Suite has been created, you would need to create a Test Case, again using the Menu options. Then I would recommend to Save the Test Suite and Test Case and reopen it, so the Selenium IDE knows of their existence.

Then you just need to do a few steps :-

  • Click on the Test Case in the Selenium IDE.
  • Next you click on the Record icon (top right). This will allow you to record the steps you take on your web browser and the steps are recorded in the Test Case as Command, Target and Value
    • Command is for the Action you take
    • Target is for the element you perform the Action
    • Value is for the Command to either match it against something else or use it in the Commands to provide an output.
  • So I have recorded a simple form and how the Selenium IDE records this all, have a look at this video (to view this video, it is best to run it in full screen mode).
  • The next step is to Save this Test Case within the Test Suite.
  • Now you can run the Test Case within the Selenium IDE. Have a look at this video (to view this video, it is best to run it in full screen mode)
  • That's it, you have created your first Test Case.

Please note - This was a simple example of how Selenium IDE could have been used and there are many different ways to perform the same test using other commands.

This looks great, but what help is out there?

Well we all know Google is our friend, so we can always use it for help and guidance.

However, within the Selenium IDE there are some important helpful features, which will help you in your quest of generating lots of Test Cases!

So just to quick run through some of the identified helpful features shown in the image. < br/> Base URL - allows you to specify the URL to base your tests.

  • Record - The record functionality is awesome to record your test command at a time. Each command can always be amended afterwards.
  • Log - This is useful for running the Test Case and seeing whether each Command passes or not and the reasoning for the failure.
  • Reference - This is really useful explaining to you the Command you have selected and what you can use for the Target and Value. 
  • Target selector - This allows you to point to an element directly, as shown in the video.
  • Speed controller - This is the bar, which allows you to run the Test Cases at a speed you desire from fast to slow. 
  • Run Test Case - Well this does exactly as it says!

There are also other cool features in the Selenium IDE, which I am looking forward to discovering very soon myself! 

Anything else?

At MMT Digital, we are also using Continuous Integration and Continuous Deployment for our Kentico web sites, so we have incorporated Selenium tests into our build process, providing us with a detailed email report on whether the tests have passed or not.

I just showed you how to create a simple test, but as the Selenium introduction mentions, it is up to you on how many tests you do, as you have the power of automated testing! And this is just a brief introduction to it all, there are far more advanced features and tips in Selenium. Look out for them!

Useful links

Selenium IDE Commands