Monday, November 8, 2010

Important points in Automation Testing

Fwd mail from : Nagesh.J
3 scenarios when we should automate (or not)
Why Automate?
A prevalent belief among IT folk is that automation, by default, will enhance the quality of testing.
How true is that belief?
“There is a time and place for everything”, as the popular idiom goes, and that holds true for test automation too.
Certain scenarios in which automation is generally a good option:
1. Repetitive Tests
A system that needs the same tests executed periodically is a good candidate for automation. Take for example, support projects that must perform regression tests for every PR/CR. Manual effort in such cases tends to be huge and error-prone. Automation can prove very efficient in such cases.
It makes sense to opt for a testing tool with a version controlled repository to manage the test scripts.
The cost of automation and the initial effort investment for script creation is usually greater than for manual testing, and it must be analyzed how far this investment will pay off in the end. A few pointers to help make that decision:
  • How many repetitions of tests are expected, for how long? A longer “life” of the test scripts tips the scale in favor of automation.
  • How expensive is the tool?
  • How much time/effort will it take to create the test scripts? Automation may not simply be record-and-play, a lot of design and coding may have to go in to achieve the desired result.
  • Are incremental changes expected to the scripts?
  • Do testers on the team require training on the tool?
“Repetitive tests => automation” is a fair thumb rule but not an inviolable one. A costly automation setup on one hand and quick-to-build on-the-fly manual tests on the other, and you might just find that automation will not be useful even if you expect a certain number of repetitions.
2. Manually Infeasible Tests
Before an application is deployed in the production environment, it might be critical to determine how the application will behave under huge user load or when dealing with millions of records.
Such test scenarios are usually best simulated with automation. In high risk conditions, where the cost of missing a test might be disastrous, even a single-time use of automation might be a worthwhile decision.
3. Low Severity/Probability Of “Human” Bugs
Automation can perform some jobs far better than a human can hope to do. Give the tool and the human tester two excel sheets with 10,000 rows of data each to reconcile with each other. No prizes for guessing who can do it faster, without errors.
But then, humans are far better at another sort of testing. Humans can notice oddities beyond documented tests. Does the UI look too cluttered? Does the mouse flicker strangely when moved over the button? Did the screen behind the modal window just blink?
Automation is limited to testing what it is programmed to do. Not everything that the human mind can observe/analyze can be programmed, and so, automation will miss out on capturing some bugs. The question to ask is: how important are those missed-out bugs? An unstable system might not be ready for automation, as severe “manual” bugs may get ignored. Automation is better suited to systems in which the “human” bugs are expected to be fewer and are of low severity.
In Closing
A point worth remembering is that automation vs. manual does not have to be an either-or decision. A mix can work. Take a multi-step workflow – a couple of steps might be fit for automation, not the entire flow. Automate only those steps that will benefit from automation.
 A quick QTP tip that may improve the performance of your scripts (for a web based app)
While working on a web applications using QTP, you may have noticed most of the time QTP runs too fast in comparison to the application. Moreover QTP would not perform any operation on a particular page unless that page has loaded completely (100%). You may wonder in bewilderment about what to do to make the application (web page) load faster.
Here I would like to give you a simple tip to alleviate your pain (and waiting time) a bit.
If you will notice carefully, most of the times text on a web page renders very quickly. It is the images that creates problem and increases the web page loading time. What if we can stop the images from loading altogether?
All browsers provides this facility whereby you can stop pictures from showing. To do this in IE6, go to Tools > Internet Options > Advanced tab. Scroll down to ‘Multimedia’ section and uncheck ‘Show pictures‘.

To do this in Firefox, go to Tools > Options > Content. Uncheck ‘Load Images automatically
Run your script now and let us know if this tip helped you. [For obvious reasons, this tip won't be of any use when you have to work on image/bitmap checkpoints.]
8 tips on advanced Regular Expressions

If you are a practitioner of regular expressions, you may be knowing, how easy it makes your life while dealing with pattern of strings. Regular Expressions is one topic, I feel, everyone in the software industry –who is even remotely related to programming- should gain mastery over. I can’t tell you enough, how many times regular expressions have came to my rescue. 
Smashing Magazine, yesterday published an interesting article on advanced usage for regular expressions.  Though the syntax they have used is PHP-Perl compatible but (after some minor changes in syntax) you can use it for VB Scripting needs as well. The underlying concepts behind reg-ex pretty much remains the same for all programming languages.
They have divided the topic into eight sub headings
  1. Greediness/Laziness
  2. Back Referencing: is a way to refer to previously matched patterns inside a regular expression. (One of my favorites)
  3. Named Groups
  4. Word Boundaries
  5. Atomic Groups
  6. Recursion
  7. Call backs
  8. Commenting
 A complete guide to working on Quality Center with QTP

Q: What are the prerequisites to connect QTP with QC?
A:
  1. Check Allow other Mercury products to run tests and components present under Tools > Options > Run in QTP
  2. If you are running the tests on the same computer where you have QC client installed, then you will need:
    1. QTP Connectivity Add-In
    2. QTP Add-in
  3. If you are running the tests on the different computer than where you have QC client installed, then you will need:
    1. QTP Add-in where QC client is installed.
    2. QTP Add-in and QC connectivity Add-in where QTP is installed.
  4. QC connectivity can be found at QC server URL > ‘Add-Ins Page’ link > ‘QC Connectivity’ link > ‘Download Add-in’
  5. QTP Add-in can be found at QC server URL > ‘Add-Ins Page’ link > ‘More QC Add-ins’ link > Download and install QTP Add-in according to its version.
Q: How can we connect QC with QTP using Automation Object Model (AOM)?
A:
Use TDConnection Object.
Example:
‘ Create the QuickTest Professional application object.
Set qtqcApp = CreateObject(”QuickTest.Application”)
qtqcApp.Launch ‘Launch QTP
qtqcApp.Visible = True ‘Make it visible
‘Connect to Quality Center
‘qtqcApp.TDConnection.Connect <QC Server path>, <Domain name that contains QC project>,
‘<Project Name in QC you want to connect to>, <UserName>, <Password>,
‘ <Whether ‘password is entered in encrypted or normal. Value is True for encrypted and FALSE for normal>
qtqcApp.TDConnection.Connect “http://QualityCenterServer/tdbin”,
“FR”, “Flights”, “learnqtp”, “welcome”, False
Q: How can we automatically connect QTP with QC on start up?
A: Go to File > Quality Center Connection. Check the box marked Reconnect to server on start-up.
Q: What if QTP tries to connect with QC automatically but QC login credentials had changed?
A: Change the following properties from 1 to 0. They are present in mic.ini file under QTP installation generally found under C:\Program Files\Mercury Interactive\QuickTest Professional\bin
  1. LoginAutomatically=0
  2. ReconnectToDB=0
  3. ReconnectToServer=0
Q: How can we access Quality Center Open Test Architecture (OTA) using AOM?
A: Using QCUtil object (AKA TDUtil for QTP 6.5 and backwards). You can find details of all associated properties like CurrentRun, TestRun, Current Testset, CurrentTestSetTest, IsConnected, QCConnection under QTP Help > Quick Test Object Model Reference > Utility Objects > QCUtil Object.
Q: Where can we find all methods and properties present under TDConnection Object?
A: Refer QTP Help > QTP Advanced References >  QuickTest Automation > TDConnection Object.
Q: How can we upload QTP scripts to QC using AOM?
A: Once connected to Quality Center, open the test using AOM and save it to QC.
Example:
qtqcApp.Open “C:\Temp\Project\QTPTestScript1″, True
‘ Get the Test object
Set qtqcTest = qtqcApp.Test
‘ Use the SaveAs method to upload the test to Quality Center
qtqcApp.Test.SaveAs “[QualityCenter] Subject\FolderName\QTPTScript”
Q: Which version of QTP is compatible with which version of Quality Center?
A: QC 9.0 integrates with QTP 8.2 SP1, QTP 8.2 SP2, QTP 9.0, QTP 9.1 and QTP 9.2. To check the compatibility of your QTP version, check out the ReadMe that comes pre-installed with QTP
Q: Can we record Quality Center operations with QTP?
A: Yes, only with QC 9.2 and above. Use .NET Add-in.
Q: Can we schedule a test run from Quality Center?
A: Yes, use ‘Test Run Scheduler’ utility that comes with QC.
Q: Is there version control in QC with QTP?
A: Yes, QTP 10.0 provides you the version control feature under the name of Quality Center Version Control present under File Menu. Earlier versions of QTP can work with 3rd party version control tools.
What to do when QTP is not able to identify browse or upload buttons
When we record using QTP and for some reason QTP does not recognize any upload buttons. For example, start the recording at this site: http://cgi-lib.berkeley.edu/ex/fup.html
Click on the "Browse" button. Notice this click is not recognized by QTP.
If you go on the link mentioned above, you will see QTP is not able to record the click on Browse web button. Web buttons are generally associated with input type=submit object but if you see the source of the browse button, you will notice input type=file object.

Now According to Microsoft help, input type=file object creates a file upload object with a text box AND Browse button. Notice the AND. So, in case of input type=file, the text box and browse button are considered part of ONE object. There are no separate objects for QTP to identify.
What can we do to solve this issue?
  1. Object Spy on the text box/ browse button object reveals that it is a WebFile type Object.
  2. Using Tools > Web Event Recording Configuration, go to WebFile (under Web Objects tree). Add onclick event.
  3. Set the onclick event settings to Always. Click ‘OK’.
  4. Done!. Record the click on browse button, now QTP should be able to identify the click on the button.

Tuesday, October 12, 2010

QTP Shortcut Key Reference Card

Mercury QuickTest Professional Shortcut Key Reference Card

File Menu
New > Test CTRL + N
New > Business Component CTRL + SHIFT + N
New > Scripted Component ALT + SHIFT + N
New > Application Area CTRL +Alt + N
Open > Test CTRL + O
Open > Business Component CTRL + SHIFT + O
Open > Application Area CTRL + ALT + O
Save CTRL + S
Export Test to Zip File CTRL + ALT + S
Import Test from Zip File CTRL + ALT + I
Print CTRL + P

Edit Menu
Cut CTRL + X (EV only)
Copy CTRL + C
Paste CTRL + V
Delete DEL
Undo CTRL + Z (EV only)
Redo CTRL + Y (EV only)
Rename Action F2
Find CTRL + F (EV only)
Replace CTRL + H (EV only)
Go To CTRL + G (EV only)
Bookmarks CTRL + B (EV only)
Complete Word CTRL + Space (EV only)
Argument Info CTRL + SHIFT + SPACE (EV only)
Apply “With” To Script CTRL + W (EV only)
Remove “With” Statements CTRL + SHIFT + W (EV only)

Insert Menu
Checkpoint > StandardCheckpoint F12
Output Value > Standard Output Value CTRL + F12
Step > Step Generator F7
New Step F8 OR INS (KV only)
New Step After Block SHIFT + F8 (KV only)
Key: KV = Keyword View
EV = Expert View

Test/Component/Application Area Menu
Record F3
Run F5
Stop F4
Analog Recording CTRL + SHIFT + F4
Low Level Recording CTRL + SHIFT + F3
Step Menu
Object Properties CTRL + ENTER
Value Configuration Options CTRL + F11 on an input value
(KV only)
Output Options CTRL + F11 on an output value
(KV only)

Debug Menu
Pause PAUSE
Step Into F11
Step Over F10
Step Out SHIFT + F11
Insert/Remove Breakpoint F9
Clear All Breakpoints CTRL + SHIFT + F9

Data Table Options
Edit > Cut CTRL + X
Edit > Copy CTRL + C
Edit > Paste CTRL + V
Edit > Clear > Contents CTRL + DEL
Edit > Insert CTRL + I
Edit > Delete CTRL + K
Edit > Fill Right CTRL + R
Edit > Fill Down CTRL + D
Edit > Find CTRL + F
Edit > Replace CTRL + H
Data > Recalc F9
Insert Multi-line Value CTRL + F2 while editing cell
Activate next/previous sheet CTRL + PAGEUP/CTRL + PAGEDOWN

General Options
View Keyword View/Expert View CTRL + TAB
Open context menu for step or Data Table cell SHIFT + F10
or Application key ( )
Expand all branches * [on numeric keypad] (KV only)
Expand branch + [on numeric keypad] (KV only)
Collapse branch - [on numeric keypad] (KV only)

Monday, September 27, 2010

Add-In Manager

QTP supports almost all industry leading technologies, but by default it does not support, with respect to add in license it supports.


Default Add- ins of QTP are:

·         Activex
·         Visual basic
·         Web.


Other available Add Ins are: .NET, Java, People soft, Siebel, TE (Terminal Emulators), SAP for GUI, Sap for Web, Oracle Apps, Web Services etc.

During QTP launching it shows Add in manger dialog box, Add in Manger lists out all available Add Ins in the company.

User needs to select appropriate Add Ins for his application or AUT.

One can select more than one Add Ins also; if we select unnecessary Add Ins QTP performance will be reduced.

Tuesday, September 14, 2010

Version History of QTP

·         Astra Quick test (Mother tool of QTP) 1.0 to 5.0
·         Quick Test Professional
·         5.6 – Nov 2002
·         6.5 – 2003
·         8.0 – 2004
·         8.2, 8.3 –2005
·         9.0,9.1-2006
·         9.2- 2007 mercury interactive
·         9.5 –2008  H.P
·         10.00 –2009 January

Wednesday, September 8, 2010

Basic features of QTP

  • QTP Launched in 2002 (Nov). By Mercury Interactive. Later taken over by HP, in 2007.
  • QTP is an Object Based Testing Tool.
  • QTP is for functional and Regression Testing.
  • It follows Keyword driven approach.
  • It supports Windows Operating Environment only.
  • It supports GUI based (Graphical user interface) and Web based Applications Automation, does not support CUI (Command user interface) Applications.
  • It has multilingual support. (It supports English, Chinese, Japanese, Korean, etc languages with respect to license.)
  • It has adapted Microsoft Visual Basic Scripting edition for programming and excel like spread sheet for Data driven testing.
  • SQL (Structured query language) embedded or inserted with QTP, so we can use SQL statements directly from QTP.
  • It can be integrated with other Tools like WinRunner and Quality Center.
  • It can be used for user interface (UI) test case automation and some limited (Non UI) Test case automation like File system operations and Data base operations.
  • It was derived from Astra QuickTest (mother tool of QTP).
  • It supports IE (Internet Explorer) only for recording tests, for execution it supports other browsers like Mozilla and AOL, opera Etc apart from IE.
  • QTP is a Desktop Application (I-Tier/Stand alone).
  • QTP has two types of License,
    • 1. Seat or Node locked License,
    • 2. Concurrent or float license
  • Seat license for one system and Concurrent License, we can use for any system but one user at any time. If we want multiple concurrent licenses we can purchase.
  • QTP has UNI code support.

Monday, August 23, 2010

Automation Basics

Test automation is the use of software to control the execution of tests, the comparison of actual outcomes to predicted outcomes, the setting up of test preconditions, and other test control and test reporting functions[1]. Commonly, test automation involves automating a manual process already in place that uses a formalized testing process.

Overview
Although manual tests may find many defects in a software application, it is a laborious and time consuming process. In addition it may not be effective in finding certain classes of defects. Test automation is a process of writing a computer program to do testing that would otherwise need to be done manually. Once tests have been automated, they can be run quickly. This is often the most cost effective method for software products that have a long maintenance life, because even minor patches over the lifetime of the application can cause features to break which were working at an earlier point in time.
There are two general approaches to test automation:

Code-driven testing. The public (usually) interfaces to classes, modules, or libraries are tested with a variety of input arguments to validate that the results that are returned are correct.
Graphical user interface testing. A testing framework generates user interface events such as keystrokes and mouse clicks, and observes the changes that result in the user interface, to validate that the observable behavior of the program is correct.
Test automation tools can be expensive, and it is usually employed in combination with manual testing. It can be made cost-effective in the longer term, especially when used repeatedly in regression testing.
One way to generate test cases automatically is model-based testing through use of a model of the system for test case generation, but research continues into a variety of alternative methodologies for doing so.[citation needed]
What to automate, when to automate, or even whether one really needs automation are crucial decisions which the testing (or development) team must make. Selecting the correct features of the product for automation largely determines the success of the automation. Automating unstable features or features that are undergoing changes should be avoided.[2]

Code-driven testing
A growing trend in software development is the use of testing frameworks such as the xUnit frameworks (for example, JUnit and NUnit) that allow the execution of unit tests to determine whether various sections of the code are acting as expected under various circumstances. Test cases describe tests that need to be run on the program to verify that the program runs as expected.
Code driven test automation is a key feature of Agile software development, where it is known as Test-driven development (TDD). Unit tests are written to define the functionality before the code is written. Only when all tests pass is the code considered complete. Proponents argue that it produces software that is both more reliable and less costly than code that is tested by manual exploration. It is considered more reliable because the code coverage is better, and because it is run constantly during development rather than once at the end of a waterfall development cycle. The developer discovers defects immediately upon making a change, when it is least expensive to fix. Finally, code refactoring is safer; transforming the code into a simpler form with less code duplication, but equivalent behavior, is much less likely to introduce new defects.

Graphical User Interface (GUI) testing
Many test automation tools provide record and playback features that allow users to interactively record user actions and replay them back any number of times, comparing actual results to those expected. The advantage of this approach is that it requires little or no software development. This approach can be applied to any application that has a graphical user interface. However, reliance on these features poses major reliability and maintainability problems. Relabelling a button or moving it to another part of the window may require the test to be re-recorded. Record and playback also often adds irrelevant activities or incorrectly records some activities.
A variation on this type of tool is for testing of web sites. Here, the "interface" is the web page. This type of tool also requires little or no software development. However, such a framework utilizes entirely different techniques because it is reading html instead of observing window events.[citation needed]
Another variation is scriptless test automation that does not use record and playback, but instead builds a model of the application under test and then enables the tester to create test cases by simply editing in test parameters and conditions. This requires no scripting skills, but has all the power and flexibility of a scripted approach. Test-case maintenance is easy, as there is no code to maintain and as the application under test changes the software objects can simply be re-learned or added. It can be applied to any GUI-based software application.

What to test
Testing tools can help automate tasks such as product installation, test data creation, GUI interaction, problem detection (consider parsing or polling agents equipped with oracles), defect logging, etc., without necessarily automating tests in an end-to-end fashion.
One must keep satisfying popular requirements when thinking of test automation:

Platform and OS independence
Data driven capability (Input Data, Output Data, Meta Data)
Customizable Reporting (DB Access, crystal reports)
Easy debugging and logging
Version control friendly – minimal binary files
Extensible & Customizable (Open APIs to be able to integrate with other tools)
Common Driver (For example, in the Java development ecosystem, that means Ant or Maven and the popular IDEs). This enables tests to integrate with the developers' workflows.
Support unattended test runs for integration with build processes and batch runs. Continuous Integration servers require this.
Email Notifications (automated notification on failure or threshold levels). This may be the test runner or tooling[clarification needed] that executes it.
Support distributed execution environment (distributed test bed)
Distributed application support (distributed SUT)
[edit] Framework approach in automation
A framework is an integrated system that sets the rules of Automation of a specific product. This system integrates the function libraries, test data sources, object details and various reusable modules. These components act as small building blocks which need to be assembled to represent a business process. The framework provides the basis of test automation and simplifies the automation effort.
There are various types of frameworks. They are categorized on the basis of the automation component they leverage. These are:

Data-driven testing
Modularity-driven testing
Keyword-driven testing
Hybrid testing
Model-based testing
[edit] Popular Test Automation Tools
Tool Name Company Name Latest Version
HP QuickTest Professional HP 10.5
IBM Rational Functional Tester IBM Rational 8.1.0.3
Rational robot IBM Rational 2001
Selenium OpenSource Tool 1.0.6
SilkTest Micro Focus 2009
TestComplete SmartBear Software 8.0
TestPartner Micro Focus 6.3
WATIR OpenSource Tool 1.6.5