Community Sites
Create your own community website and start earning today !
It's Free !
 
Communities Members BookmarksPolls Fresher Jobs Funny Photos B.Tech Projects New Member FAQ  



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter




Automated Webpage Testing using Python


Posted Date: 13 Jun 2008    Resource Type: Articles/Knowledge Sharing    Category: Computer & Technology

Posted By: mohan       Member Level: Gold
Rating:     Points: 1



When I was a part of the BT Wholesale Portal team, we used to develop web based applications. Each application had a web front end, a J2EE middle layer (business logic) and a database back-end. In addition to the development team, we had a testing team - a crucial part of the delivery process - as we are rarely able to deliver 100% bug free code for each application.

As my modules were being tested, I had to interact with the testing team. The testing team used to test web pages manually. As usage of tools like Empirix (www.empirix.com) was in the initial stages, much of the testing was manual. I am not aware of the present status, as I have moved to a different project.

At that time, during my interaction with members of the testing team, I asked them why they were not using some form for automation for web page testing. The reason for not using automation was non-availability of tools, licensing issues and non-availability of requisite permissions from the client.

Though I suggested to them that something might be possible using a tool like Perl, I did not pursue the matter, as I did not have the time and the team did not have Perl experience to try things on their own. While I continued with other things and eventually moved to a different project, the idea of building a custom tool remained firmly in my mind.

Many of the you might be asking "Why Perl?" Creating such a tool using C++ and Java is quite a task. Compared to these languages, Perl is easier as the language is meant for data processing/crunching and testing of web pages would involve a lot of data manipulation and string processing.

When I had some time, I explored the extensive CPAN (Comprehensive Perl Archive Network - www.cpan.org) site for appropriate Perl packages. Take some time to visit this site. The number of packages available is extremely large (some stats of the site - 2008-05-21 online since 1995-10-26; 4466 MB; 236 mirrors; 6627 authors; 13602 modules). I tried some packages like WWW:Mechanize, Test:WWW:Mechanize, etc from the archive. Due to project requirements, I had to freeze this experiment.

Recently, I wanted to unfreeze that experiment. After a few days with Perl, I decided to continue this experiment in a different language - I am a casual user of Perl and Perl syntax is such that I tend to forget it if Perl code is left unattended for a few weeks. Initially I considered Ruby. After realizing that Python has been around for a longer time than Ruby and hence the chances of find some useful packages in Python were more, I decided to learn Python.

Python is a very simple language to learn and developing applications is straightforward. I studied Python and the packages available - bundled with the language and developed by other people. Over a period of a couple of months, I was comfortable with Python and was in a position to give the web page tester a shot.

I started building the application in bit is pieces, by exploring the following

how to download a web page
how to download the page through the TechM proxy
how to parse the html
how to perform requisite tests on the page

Finally, I was able to put together an application that allows me to download a page from the Internet, parse it and test it based on given parameters. Consider a sample scenario. Suppose we wish to test the home page of BT Wholesale. We know that the home page of the site contains a title tag, with the text "BT Wholesale". Using the Python web page tester, we can test this precisely. To do so, we need to write a Python application, download and parse the web page and search for the specified text (all this using the classes in the Python web tester application). When we find the specified text, we can declare the test a success. If we are not able to find the specified text, the test is a failure.

Being able to perform such tests on the downloaded page satisfied my requirements for the application. Finally, I had a custom test suite that allows me to test web page automatically, reducing my need and effort of manual testing. With a program at my disposal, all I need to do is to execute the program and check the result. I do not need to launch the browser, connect to the page and verify the page to check if it has changed. The program does that for me.

Even though my requirements were satisfied, there was a small hurdle - the page tests were Python applications. Asking users to write Python applications would reduce the acceptability of the application. Hence I decided to create an application that would read an input file and perform the required tests without asking the user to write Python code. I created an XML specification for the input file and tried the application once again. With the XML input file, I need to specify the tests to be performed using a simple file - no Python code - and the application will perform the tests for me and display the results.

Automatically testing a web page is now a simple job

Create the XML input file
specify details of the web proxy to be used (if required)
specify details of the the web page to be tested
specify the various test to be performed on the web page - one test node per test
Execute the automated tester
Check the results generated

Sometimes, instead of relying blindly on existing techniques and tools, it might be worthwhile to invest some time into creating a custom tool that will ease the way we work. Such a tool surely helps us apply the oft quoted phrase "work smarter, not harder".

PS: In case you are interested in the tool, let me know and we can take this further.




Responses

Author: hari    13 Jun 2008Member Level: Silver   Points : 2
Wow, Does the python is used for the testing purpose?

I know that the python is an programming language .

Is this the newer enhancement for the python?




Author: Tejwant Singh Randhawa    16 Jun 2008Member Level: Silver   Points : 1
really very nice.
i never heard something like that done with the python.
this article is really exceptional.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: New version of encryption Virus
Previous Resource: How to hack your Nokia Phone and Install unsigned Applications!!!
Return to Discussion Resource Index
Post New Resource
Category: Computer & Technology


Post resources and earn money!
 
Related Resources



Watch TV Channels
  • Watch Asianet TV online
  • Kairali TV in Internet
  • Surya TV online
  • Amritha TV Channel

  • Contact Us    Privacy Policy    Terms Of Use   

    SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.