https://www.qatechies.com

HP QTP Utility Statements : GetLastError Statement

technical-concept-uft

HP QTP Utility Statements : GetLastError Statement


Welcome to this post! – ” HP QTP Utility Statements : GetLastError Statement”.

If you are looking for HP UFT, QTP utility statements and their usages, then you are at right place. This post “HP QTP Utility Statements : GetLastError Statement” consists of concept discussion and usage discussion. Go ahead and enjoy reading…

This discussion will help you prepare well if you are going for the interview and can help you if you need the function to be used in your project test suite.

 

GetLastError Statement

Abstract

The GetLastError statement is used to get the latest error found in the execution or the run, and requires you to associate the last error via this statement to get the actual verbal description of the same. The statement in itself falls under the category of utility statements and not utility objects. Remember there is a difference between utility statements and utility objects.

Before we dig down deep into the usage let’s quickly visit some general questions.

In the interview usually, you might be questioned in different ways like:

  1. How to get latest error description in the test run?
  2. Can you associate the getLastError statement value to DescribeResult statement?
  3. What are the objects and parameters of GetLastError statement?
  4. is GetLastError is an object or statement?
  5. How can you show the description of last error occurred in the execution?

 

Discussion

When you create the test using some framework like hybrid, keyword driven or data driven, there is always a possibility of running into error. There are various errors which occur in the execution these can be number related, object related, system related etc. Whatever the case be if you want to proceed to next step then you can get the last error code via statement getLastError.

Usually tester use the on error goto statement to return the code status to 0. But it’s a good practice to keep the error description in the log so that later you can analyze the log for pass and failures.

Hence, officially the main purpose of the GetLastError statement is to return the error code of the most recent error. You can use this statement together with the DescribeResult statement.

 

Points to note here:

  1. You can add this statement manually in the Expert View.
  2. Always use the GetLastError Statement to get the last error code and publish its description using DescribeResult statement in the log.

 

Syntax

GetLastError

 

Return Value

Number

 

Example

In the following example, the script fails to run successfully because the Password Image was not found on the Mercury Tours page.

The error code of the error is retrieved using the GetLastError statement, and then the DescribeResult statement displays the text description of the error code in a message box.

'GetLastError example

Browser("Mercury Tours").Page("Mercury Tours").Image("Password").Click 21, 30 

x = GetLastError 

msgbox(DescribeResult(x))

 

 

This brings us to the end of our discussion on “HP QTP Utility Statements : GetLastError Statement”.

 

I really hope you have enjoyed reading this short post. If you have any doubt on this please feel free to add your comment below.


Other Utility Statements:
UNREGISTERUSERFUNC REGISTERUSERFUNC
SETLASTERROR GETLASTERROR
INVOKEAPPLICATION EXITTEST
EXITACTION EXITACTIONITERATION
DESCRIBERESULT EXECUTEFILE
EXITCOMPONENT EXITCOMPONENTITERATION
LOADANDRUNACTION PRINT
WAIT EXITTESTITERATION
LOADFUNCTIONLIBRARY CALLSERVICETEST
OBSOLETE MANUALSTEP
RUNACTION  

And if you like to read more on UFT or QTP Technical Interview Questions please follow below links: 

UFT Technical Interview Questions – Set 1

UFT Technical Interview Questions – Set 2

How to Download Resource From QC\ALM?

How to Upload Resource To QC\ALM?

 

Or if you prefer General Interview Questions please follow below links:

UFT General Interview Questions – Part 1

UFT General Interview Questions – Part 2

 


If you would like to keep track of further articles on UFT (QTP). I recommend you to SUBSCRIBE by Email and have new UFT articles sent directly to your inbox.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

advanced-floating-content-close-btn
https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5034726663464946 (adsbygoogle = window.adsbygoogle || []).push({});
advanced-floating-content-close-btn 
*************************** Do you want to learn TOSCA? Do you want to excel in Career? Try my New Courses: 1. Tricentis Tosca and Working with Excel   2. Tricentis Tosca and UI Automation Great News!!   Price has been slashed down for limited period of time.So Hurry!!! Click The Shown Links and Enjoy Learning. ***************************
 
error: Content is protected !!