Tuesday 16 August 2011

Selenium With Python - Introduction

The below details describe about the use of Selenium RC using the Python scripting language. I have mentioned all the required details like how to use Selenium Server, Selenium IDE and Python client libraries.


What is Selenium?
Selenium is a software testing framework for web applications. Selenium was developed by a team of programmers and testers at Thought Works. The tests can be written as HTML tables or coded in a number of popular programming languages and can be run directly in most modern web browsers.

Selenium Components –
        Selenium IDE
        Selenium Core
        Selenium Remote Control (RC)
        Selenium Grid

Please see below brief about Selenium IDE and in details about Selenium RC.

Selenium IDE
1. Selenium IDE features:
  • record/play mechanism: create/edit tests by recording the user actions on the page
  • Debugging feature with step-by-step and breakpoints
  • Page abstraction capabilities
  • Automatic assertions for the page title
  • An extensibility feature allowing the use of plug-in or user extensions that extend the capabilities of Selenium IDE

2. Installation

Selenium IDE is distributed as Firefox extension:
  1. Go to the Selenium website (http://www.seleniumhq.org) or the Firefox add-ons website (http://addons.mozilla.org)
  2. Download the latest release (1.0.8 at the time of writing)
  3. Follow the instructions and restart Firefox
  4. Selenium IDE is accessible from the ‘Tools’ Menu of Firefox
 

Selenium RC

Selenium-RC allows the test automation developer to use a programming language for maximum flexibility and extensibility in developing test logic. For instance, if the application under test returns a result set, and if the automated test program needs to run tests on each element in the result set, the programming language’s iteration support can be used to iterate through the result set, calling Selenium commands to run tests on each item.

Selenium-RC provides an API (Application Programming Interface) and library for each of its supported languages: HTML, Java, C#, Perl, PHP, Python, and Ruby. This ability to use Selenium-RC with a high-level programming language to develop test cases also allows the automated testing to be integrated with a project’s automated build environment.
Selenium RC comes in two parts.
  1. A server which automatically launches and kills browsers, and acts as a HTTP proxy for web requests from them.
  2. Client libraries for your favorite computer language.

1. Selenium Server

  • Selenium server is the program that drives the browser
  • It embeds Selenium Core framework and injects it into the browser
  • It communicates with the running test client and drives the browser
  • Client tests sends commands that the server interpretes in order to drive the browser
  • The server sends back results to the client
  • Client and server communicates via HTTP GETs and POSTs so you can easily plug into
  • Server is configurable at startup via command-line options. use java -jar selenium-server.jar -h to see the list of options

2. Client libraries

  • Client libraries provides the API to program tests and execute them on the server
  • Each implementation provides access to all Selenium commands
·         Supported API implementation exists in:
    • Java
    • .Net
    • PHP
    • Python
    • Perl
    • Ruby
Pre-Requisites –

Selenium Server –
Java Runtime Environment (JRE) 1.6 is recommended to run Selenium server.

Python Client Libraries
Python should be installed (Python 3.x is not yet supported)
Python Window (PyWin32)
Setup Tool
Python-Selenium libraries

No comments:

Post a Comment