Skip to main content

Error Handling and Recovery Scenarios in QTP - Part-1

Just think… What type of errors/blockers we get when testing an application? (in Manual Testing)
    1. Defects in Application
    2. System Environment Issues like Browser is getting closed automatically
    3. Application Down for some time
    4. Unexpected Popup Windows which are not documented in Testcase
These are some sample issues in manual testing. What will a manual tester do in above situations?
Simple. He will use some sense. If there are defects, He will stop executing that testcase and reports it. If browser got closed He will reopen the browser and continues the execution. If application is down, He will stop executing the testcases. He will take the required action for Popup windows. He can do because he can change his mind dynamically.
When it comes to Automation, the script will play the role of manual tester. But the Automation Tester should provide enough intelligence to the script to handle above errors like the way how those handled manually.
To provide that strength to the script, Automation Tester will use VB Script Err Object and Recovery Scenarios.
So what type of errors we get when executing a script?
    1. Popup Windows (Security Popups)
    2. Object State Change (Application Down/ Display of Validation Errors)
    3. Script Errors (Due to poor coding)
    4. Sudden Death of Application (Computer Problem/OS Problem)
How Recovery Scenarios will provide strength to Script?
Recovery Scenarios are useful to continue the execution when it is interrupted by any unexpected event/error. When error occurs, the error information will be collected by QTP Recovery Mechanism and a predefine recovery scenario will be executed to overcome the error and to continue the execution. The predefined recovery scenarios will be developed by the Automation Tester.
A Recovery Scenario consists of 3 sections
    1. Type of Error
    2. What is the operation you want to perform (To Overcome the Error)
    3. What do you want to do after performing the operation (To Continue the execution)
The Automation Tester will think of every possible error that might occur in execution time and prepares recovery scenarios for them as per the above model and associate them in Test Settings of QTP Test.
clip_image001
Figure 1: Associated Recovery Scenarios
When execution got interrupted due to an error, QTP applies the specified Recovery Scenarios as per the prioritization. The Recovery Operation will be executed when the error details specified in Recovery Scenario got matched with the error that is caused interruption to the execution.
How to Define a Recovery Scenario?
Technically the above 3 sections are called as below
    1. Trigger Event
    2. Recovery Operation
    3. Post Recovery Operation
Trigger EventThe type of event that is causing interruption to the execution.
Type of Trigger Events:
    1. Popup Window
    2. Object State
    3. Test Run Error
    4. Application Crash
clip_image002
Figure 2: Trigger Events
The below information is required for each trigger event. This information will be used to match the errors that are occurred in execution time.
Trigger EventRequired Details to Specify
Popup WindowWindow Details
Object StateObject Details (specify the properties of the object with values)
Test Run ErrorType of Error
Application CrashApplication Process Name
Recovery OperationThe operations that are required to clear the errors/blockers that are interrupted the execution. The Recovery Operation will be executed only when Trigger Details and Error details are matched.
The below recovery operations available in QTP
    1. Keyboard or Mouse Operation
    2. Close Application Process
    3. Function Call
    4. Restart Microsoft Windows
clip_image003
Figure 3: Recovery Operations
Keyboard or Mouse Operation
A Keyboard stroke/ Mouse click will be performed. It will be used when there is only one step operation is required. Ex: Click a button
Close Application Process
The specified process will be closed. It will be used when any other application is interrupting execution. Ex: An antivirus system blocking execution.
Function Call
A library function will be called. It will be used when there are multiple steps need to be executed. Ex: When providing functional alternative, When you want to analyze the error and perform operation
Restart Microsoft Windows
QTP Restarts the Operating System. This will be used when the execution blocked because of a pending restart.
Post Recovery OperationsRecovery Operation used to clear the errors/blockers of execution.
But Post Recovery Operations provide a facility on how you want to continue the execution after performing the Recovery Operation.
The below are Post Recovery Operations
  1. Repeat current step and continue
  2. Proceed to next step
  3. Proceed to next action or component iteration
  4. Proceed to next test iteration
  5. Restart current test run
  6. Stop the test run
clip_image004
Figure 4: Post Recovery Operations
Why Post Recovery Operations are required?
What will happen when an Application got crashed? We will reopen the application. But how the execution will be continued? If 50 steps are executed for a script, How recovery operation will execute those 50 steps and continues the execution. No way. This type of cases we just use Restart Current Test Run as Post Recovery Operation.
So Post Recovery Operations are useful to continue the execution based on the performed Recovery Operation. It’s also useful to quit the execution in proper way.
Repeat Current Step and Continue
By default Recovery Scenarios will be executed when execution got interrupted due to an error. There is a facility to execute recovery scenarios for each step. I.e. whether you get error or not Recovery Scenarios will be executed. Executing them for each step will make low performance for the script and hence by default the Recovery Scenarios will be activated on error (Observe Figure1).
QTP understands that there is an error only when a step got failed. If that is important step and recovery operation is covering it then we choose Repeat Current Step and Continue option.
Ex: Login button got disabled QTP tries to click on it and failed. Recovery operation did something to enable Login button. QTP already executed clicking on Login button and it will try to execute next step which will become fail. In this case “Repeat Current Step and Continue” will make QTP to re-execute the clicking on login button step.
Proceed to Next Step
If the failed is not important or if Recovery Operation completely clears the way for execution then this option will be useful.
Proceed to next Action or Component Iteration
Exit from current Action iteration and starts executing next Iteration. This will be used when a Test is using Actions concept and you want to skip the only that Action iteration execution. This option is useful to execute the same Action with next set of data that is available in datatable. Component is the concept of BPT (Business Process Test).
Proceed to next Test Iteration
Exit from current Test iteration and starts executing next Iteration. This option is useful to execute the same Test with next set of data that is available in datatable. The above two are based Iterations concept. 
Restart current test run
Restart the current Test Run. This option is used when there is the functional flow got disturbed and not able to continue the execution.
Stop the Test Run
Stops running that Test. This will be used when application is down or an open defect still there and no need to continue the execution of that test.

Comments

Popular posts from this blog

JMeter Exceeded Maximum Number of Redirects Error Solution

While running performance test, JMeter allows maximum 5 redirects by default. However, if your system demands more than 5 redirects, it may result in JMeter exceeded maximum number of redirects error. In this post, we have listed down steps to overcome this error. Actual error in JMeter: Response code: “Non HTTP response code: java.io.IOException” Response message: “Non HTTP response message: Exceeded maximum number of redirects: 5” This error is noticed because  JMeter  allows maximum 5 redirects by default and your system may be using more than 5 redirects. You need to increase this count to more than 5 in jmeter.properties file. Follow below steps to achieve this. Navigate to /bin directory of your JMeter installation. Locate jmeter.properties file and open it in any editor. Search for “httpsampler.max_redirects” property in opened file. Uncomment the above property by removing # before it. Change to value to more than 5 Eg. 20. Save the file and restart JMeter. If

SSO with SAML login scenario in JMeter

SAML(Security Assertion Markup Language) is increasingly being used to perform single sign-on(SSO) operations. As WikiPedia puts it, SAML is an XML-based open standard data format for exchanging authentication and authorization data between parties, in particular, between an identity provider and a service provider. With the rise in use of SAML in web applications, we may need to handle this in JMeter. This step-by-step tutorial shows SAML JMeter scenario to perform login operation. First request from JMeter is a GET request to fetch Login page. We need to fetch two values ‘SAMLRequest’ and ‘RelayState’ from the Login page response data. We can do this by using  Regular Expression Extractor . These two values need to be sent in POST request to service provider. Refer below image to see how to do this. We will get an HTML login page as a response to the request sent in 1st step. We need to fetch values of some hidden elements to pass it in the next request. We can do this b

A Tutorial to Send Email using JMeter

Sending email is a mundane activity in any professional’s life. It’s a common medium for communication nowadays. Therefore performance testing of email server is not only important but necessary for an organization. JMeter can be helpful to perform load testing in such scenarios. In this tutorial, we will see how JMeter can be used to send email. We will use SMTP Sampler of JMeter to send an email. JavaMail API is needed to enable email functionality in JMeter. Download it from  here  and paste the jar in JMeter’s lib folder. Now, perform below steps to configure SMTP Sampler. Add a new Thread Group under Test Plan. Right click on Thread Group and select Add–>Sampler–>SMTP Sampler. We need to populate SMTP server’s details in this sampler. We will use GMail for sending an email. For this, enter these values in SMTP Sampler fields. Server: smtp.googlemail.com, Port: 587. Provide values in Email Address From and To fields of Mail Settings section to specify sender and reci