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.