Total Pageviews

Donate

Feb 21, 2015

Automated UI Testing in Python

During the last year 2014, I was exposed to behavior testing. As I mentioned in my last blog post about agile team building, me and my team applied different automated testing techniques including the behavior testing using Gherkin. In fact, this was - and still - a very hard task to maintain these tests, especially with the unstoppable flow of business changes. Behavior testing is all about complete features and their different scenarios. In other words, it is all about testing the UI being interacted by the system users to apply their business needs. Below I'm going to list why it is not very easy to maintain these tests and after that I will show a new technique that can make it maintainable. But first let's talk a little bit about Selenium and Python Webdriver.

Automating UI Interaction (Selenium) 

Selenium is a web apps software testing framework, and its name came from a joke by the original creator Jason Huggins in an email. He was making a joke of a competitor - Mercury by HP - saying that: "you can cure mercury poisoning by taking selenium supplements" :)
Huggins developed Selenium during 2004 while he was at ThoughtWorks. He joined Google in 2007 completing his work on Selenium. At the same time, ThoughtWorks was working on the development of a browser automation tool called WebDriver. In 2009 these two project has been combined together to produce a new product called Selenium 2.0 or in other words Selenium WebDriver. Now Selenium 2.x is almost the most powerful UI test automation tool and has become a kind of a 'de facto standard' for test automation. Selenium IDE is a Mozella Firefox extension that works as an integrated development environment for Selenium scripts called Selenese. Selenese is a special test scripting language for Selenium.  Selenium Remote Control (RC) is a server written in Java that accepts Selenium command for browser through HTTP. It allows to write automated tests using any programming language that facilitated integrating Selenium in already existing testing frameworks. Selenium client API  is an alternative to writing tests in Selenese that can be written in many languages like Python, Java, C#, and Ruby. Now in Selenium 2, Client API include WebDriver as a central component.
In the following section I'll give an example of how tests can be written using Python Client API.

Donate