For some months, I have been using Selenium WebDriver a lot for automating the web testing procedures. If you haven’t heard of this piece of software yet, I highly recommend it to anyone in the software testing industry and for anyone who often performs repetitive tasks in a web browser.
This means that you will be able to automate a lot of the work you might have used to do manually. Think of a web application that you work on. You probably have certain tests you perform over and over every build or release and find yourself doing the same thing again and again. When the number of things to check gets large, it is also easy to miss a certain workflow which could have negative consequences in the QA/QC terms. Having a script for the tests will serve as a documentation for your colleagues. The script is also easy to extend to accumulate the regression test cases. The script can be executed as scheduled without you doing anything at all which might be a huge time saver.
Sounds interesting? Start at the Selenium home page. Navigate to the Download and download Selenium Client & WebDriver Language Binding of your choice (I am using Python binding). After downloading and installing the module, fire up your IDE (I use Wing IDE and like it very much) and let’s build a simple script.
Navigate to this example. Remember to choose the language you want to see examples in within the Programming Language Preference section that will follow you on the screen. Then you will see the code only in one language. The official Selenium documentation is great and the API itself is very intuitive and easy to get started. After finishing the tutorials and playing a bit, consider writing some small unit tests for the web application you work on. If you use Python, unittest module is probably the best to start with and you could wrap your Selenium script into individual test cases and run them from the command line or IDE of your choice.
If you have access to Pluralsight, there is a great course by John Sonmez called Automated Web Testing with Selenium. It helped me to get on track in no time at all and I highly recommend this one.
If you want to perform some tests that involve interacting with web map components and GIS functionality, you might find it hard to find any useful information on any best practices or helpful tips where to start.
Here are some useful features of Selenium you should be aware of:
- You can take screenshots of the web browser while the program is executed. This implies that you will be able to open the saved images later on and review the web application visually if there are some parts that are hard to test automatically (such as the layout design). Having an image of how the web application looked like earlier, you could use any image comparison algorithm (like PIL in Python) to find what have changed in the web application.
- It is possible to resize the window with the browser opened so it will not obstruct other open windows.