Automation


380316678_0c67948cb7_o1.jpg

Python is a great choice for software, web apps and test development with just about anything you can think of – including Selenium, Pytest, Jenkins, GitHub, BitBucket and Sauce Labs.

The current number of packages available for Python today, as of this writing, is an astonishing 153,518.

Python ships with two unit test suites, Unittest and Nose – and easily runs with another suite gaining popularity – Pytest.

In case you haven’t seen it yet – here’s the Zen of Python:

 

The Zen of Python

 

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

 

Selenium is an open-source tool that attaches to the browser via various schemes and can simulate user actions on any webpage. Not only can testing be done, but any boring task repeatedly done on a webpage can be automated with Selenium.

Here’s a video showing Selenium Automation on a website:

 


 

This video shows the Eclipse IDE running a web test written with Selenium, Java, JUnit, Log4j2, Maven, awt.Robot and other packages. It tests against my own website: schorrmedia.com which is also known as schorrmedia.com.

The tests are run with JUnit, so each test stands on its own and can be run independently of the others. Each test launches a fresh instance of Firefox with Selenium WebDriver. The tests use Maven and a Maven pom.xml file to specify dependencies. The entire suite was written in and runs with Eclipse on Windows 7.

The source code can be viewed on GitHub at:
http://git.io/vC7wp

This demo was done with inverted color on a Windows 7 machine. I’m using inverted color a lot lately because it’s easier on the eyes.

The script also includes full Maven Surefire site test result reporting. To read more about Selenium, see: http://www.seleniumhq.org