Python Testing Cookbook — Save 50%
Over 70 simple but incredibly effective recipes for taking control of automated testing using powerful Python testing tools
The Robot Framework is a useful framework for writing acceptance tests using the keyword approach. Keywords are short-hand commands that are provided by various libraries and can also be user defined. This easily supports BDD-style Given-When-Then keywords. It also opens the door to third-party libraries defining custom keywords to integrate with other test tools, such as Selenium. It also means acceptance tests written using Robot Framework aren't confined to web applications.
This article by Greg Lee Turnquist, author of Python Testing Cookbook, shows all the steps needed to install the Robot Framework as well as the third party Robot Framework Selenium Library.
|Read more about this book|
(For more resources on Python, see here.)
How to do it...
- Be sure to activate your virtualenv sandbox.
- Install by typing: easy_install robotframework.
- Using any type of window navigator, go to <virtualenv root>/build/robotframework/doc/quickstart and open quickstart.html with your favorite browser. This is not only a guide but also a runnable test suite.
- Switch to your virtualenv's build directory for Robot Framework: cd <virtualenv root>/build/robotframework/doc/quickstart.
- Run the Quick Start manual through pybot to verify installation: pybot quickstart.html.
- Inspect the generated report.html, log.html, and output.xml files generated by the test run.
- Install the Robot Framework Selenium library to allow integration with Selenium by first downloading: http://robotframework-seleniumlibrary.googlecode.com/files/robotframework-seleniumlibrary-2.5.tar.gz.
- Unpack the tarball.
- Switch to the directory: cd robotframework-seleniumlibrary-2.5.
- Install the package: python setup.py install.
- Switch to the demo directory: cd demo.
- Start up the demo web app: python rundemo.py demoapp start.
- Start up the Selenium server: python rundemo.py selenium start.
- Run the demo tests: pybot login_tests.
- Shutdown the demo web app: python rundemo.py demoapp stop.
- Shutdown the Selenium server: python rundemo.py selenium stop.
- Inspect the generated report.html, log.html, output.xml, and selenium_log.txt files generated by the test run.
With this recipe, we have installed the Robot Framework and one third-party library that integrates Robot with Selenium.
- Inheritance in Python [Article]
- Python Testing: Mock Objects [Article]
- Python: Unit Testing with Doctest [Article]
- Tips & Tricks on MySQL for Python [Article]
- Testing Tools and Techniques in Python [Article]
eBook Price: $26.99
Book Price: $44.99
About the Author :
Greg has worked since 1997 as a software engineer at Harris Corporation, always seeking the right tool for the job. Since 2002, Greg has been part of the senior software team working on Harris' $3.5 billion FAA telco program, architecting mission-critical enterprise apps while managing a software team. He provides after hours support and 2nd-level engineering to support the nation-wide telco network and is no stranger to midnight failures and software triage. In 2010, Greg joined the SpringSource division of VMware.
Being a test-bitten script junky, Greg has used JUnit, TestNG, JMock, FEST, PyUnit, and pMock testing frameworks, along with other agile practices to produce top-quality code.
He has worked with Java, Spring, Spring Security, AspectJ, and Jython technologies and also developed sophisticated scripts for *nix and Windows platforms. Being a wiki evangelist, he also deployed a LAMP-based wiki website to provide finger-tip knowledge to users.
In 2006, Greg created the Spring Python project. The Spring Framework provided many useful features, and he wanted those same features available when working with Python.
Greg completed a master's degree in Computer Engineering at Auburn University, and lives in the United States with his family.