Tuesday, January 29, 2019




Select Trigger Event Page


Relevant for: GUI tests and components
This page enables you to define the event type that triggers the recovery scenario, and the way in which UFTrecognizes the event.
Wizard map
The Recovery Scenario Wizard contains:
Note: Pages that are in parentheses open according to the option selected in the previous page. Therefore, not all pages are displayed for every option.
Important information
  • The set of recovery operations is performed for each occurrence of the trigger event criteria.
    Example: If you define a specific object state, and two objects match this state, the set of recovery operations is performed two times, once for each object that matches the specified state.
  • The recovery mechanism does not handle triggers that occur in the last step of a test or component. If you need to recover from an unexpected event or error that may occur in the last step, you can do this by adding an extra step to the end of your test or component.
User interface elements are described below:
UI Elements
Description
Pop-up window
Detects a pop-up window and identifies it according to the window title and textual content.
Example: A message box may open during a run session, indicating that the printer is out of paper. UFT can detect this window and activate a defined recovery scenario to continue the run session.
Object state
Detects a specific test object state and identifies it according to its property values and the property values of all its ancestors. Note that an object is identified only by its property values, and not by its class.
Example: A specific button in a dialog box may be disabled when a specific process is open. UFT can detect the object property state of the button that occurs when this problematic process is open and activate a defined recovery scenario to close the process and continue the run session.
Test run error
Detects a run error and identifies it by a failed return value from a method.
Example: UFT may not be able to identify a menu item specified in the method argument, due to the fact that the menu item is not available at a specific point during the run session. UFT can detect this run error and activate a defined recovery scenario to continue the run session.
Application crash
Detects an application crash and identifies it according to a predefined list of applications.
Example: A secondary application may crash when a certain step is performed in the run session. You want to be sure that the run session does not fail because of this crash, which may indicate a different problem with your application. UFT can detect this application crash and activate a defined recovery scenario to continue the run session.

Sources: microfocus.com


Trigger Event Screen In QTP Automation Testing


The Select Trigger Event screen enables you to define the event type that triggers the recovery scenario, and the way in which QuickTest recognizes the event. 


Select a type of trigger and click Next. The next screen displayed in the wizard depends on which of the following trigger types you select:

  • Pop-up window. QuickTest detects a pop-up window and identifies it according to the window title and textual content. For example, a message box may open during a run session, indicating that the printer is out of paper. QuickTest can detect this window and activate a defined recovery scenario to continue the run session.
  • Select this option and click Next to continue to the Specify Pop-up Window Conditions Screen.

  • Object state. QuickTest detects a specific test object state and identifies it according to its property values and the property values of all its ancestors. Note that an object is identified only by its property values, and not by its class.
  • For example, a specific button in a dialog box may be disabled when a specific process is open. QuickTest can detect the object property state of the button that occurs when this problematic process is open and activate a defined recovery scenario to close the process and continue the run session.
    Select this option and click Next to continue to the Select-Object Screen.

  • Test run error. QuickTest detects a run error and identifies it by a failed return value from a method. For example, QuickTest may not be able to identify a menu item specified in the method argument, due to the fact that the menu item is not available at a specific point during the run session. QuickTest can detect this run error and activate a defined recovery scenario to continue the run session.
  • Select this option and click Next to continue to the Select Test Run Error Screen.

  • Application crash. QuickTest detects an application crash and identifies it according to a predefined list of applications. For example, a secondary application may crash when a certain step is performed in the run session. You want to be sure that the run session does not fail because of this crash, which may indicate a different problem with your application. QuickTest can detect this application crash and activate a defined recovery scenario to continue the run session.
  • Select this option and click Next to continue to the Recovery Operations Screen.
    Notes:

    • The set of recovery operations is performed for each occurrence of the trigger event criteria. For example, suppose you define a specific object state, and two objects match this state, the set of recovery operations is performed two times, once for each object that matches the specified state.

    • The recovery mechanism does not handle triggers that occur in the last step of a test or component. If you need to recover from an unexpected event or error that may occur in the last step of a test or component, you can do this by adding an extra step to the end of your test or component.


VBScript Built-in functions use in UFT.

Abs Function: Returns the absolute value of a number.
Array Function: Returns a Variant containing an array.
Asc Function: Returns the ANSI character code corresponding to the first letter in a string.
Atn Function: Returns the arctangent of a number.
CBool Function: Returns an expression that has been converted to a Variant of subtype Boolean.
CByte Function: Returns an expression that has been converted to a Variant of subtype Byte.
CCur Function: Returns an expression that has been converted to a Variant of subtype Currency.
CDate Function: Returns an expression that has been converted to a Variant of subtype Date.
CDbl Function: Returns an expression that has been converted to a Variant of subtype Double.
Chr Function: Returns the character associated with the specified ANSI character code.
CInt Function: Returns an expression that has been converted to a Variant of subtype Integer.
CLng Function: Returns an expression that has been converted to a Variant of subtype Long.
Cos Function: Returns the cosine of an angle.
CreateObject Function: Creates and returns a reference to an Automation object.
CSng Function: Returns an expression that has been converted to a Variant of subtype Single.
CStr Function: Returns an expression that has been converted to a Variant of subtype String.
Date Function: Returns the current system date.
DateAdd Function: Returns a date to which a specified time interval has been added.
DateDiff Function: Returns the number of intervals between two dates.
DatePart Function: Returns the specified part of a given date.
DateSerial Function: Returns a Variant of subtype Date for a specified year, month, and day.
DateValue Function: Returns a Variant of subtype Date.
Day Function: Returns a whole number between 1 and 31, inclusive, representing the day of the month.
Eval Function: Evaluates an expression and returns the result.
Exp Function: Returns e (the base of natural logarithms) raised to a power.
Filter Function: Returns a zero-based array containing subset of a string array based on a specified filter criteria.
Fix Function: Returns the integer portion of a number.
FormatCurrency Function: Returns an expression formatted as a currency value using the currency symbol defined in the system control panel.
FormatDateTime Function: Returns an expression formatted as a date or time.
FormatNumber Function: Returns an expression formatted as a number.
FormatPercent Function: Returns an expression formatted as a percentage (multiplied by 100) with a trailing % character.
GetLocale Function: Returns the current locale ID value.
GetObject Function: Returns a reference to an Automation object from a file.
GetRef Function: Returns a reference to a procedure that can be bound to an event.
Hex Function: Returns a string representing the hexadecimal value of a number.
Hour Function: Returns a whole number between 0 and 23, inclusive, representing the hour of the day.
InputBox Function: Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns the contents of the text box.
InStr Function: Returns the position of the first occurrence of one string within another.
InStrRev Function: Returns the position of an occurrence of one string within another, from the end of string.
Int Function: Returns the integer portion of a number.
IsArray Function: Returns a Boolean value indicating whether a variable is an array.
IsDate Function: Returns a Boolean value indicating whether an expression can be converted to a date.
IsEmpty Function: Returns a Boolean value indicating whether a variable has been initialized.
IsNull Function: Returns a Boolean value that indicates whether an expression contains no valid data (Null).
IsNumeric Function: Returns a Boolean value indicating whether an expression can be evaluated as a number.
IsObject Function: Returns a Boolean value indicating whether an expression references a valid Automation object.
Join Function: Returns a string created by joining a number of substrings contained in an array.
LBound Function: Returns the smallest available subscript for the indicated dimension of an array.
LCase Function: Returns a string that has been converted to lowercase.
Left Function: Returns a specified number of characters from the left side of a string.
Len Function: Returns the number of characters in a string or the number of bytes required to store a variable.
LoadPicture Function: Returns a picture object. Available only on 32-bit platforms.
Log Function: Returns the natural logarithm of a number.
LTrim Function: Returns a copy of a string without leading spaces.
Mid Function: Returns a specified number of characters from a string.
Minute Function: Returns a whole number between 0 and 59, inclusive, representing the minute of the hour.
Month Function: Returns a whole number between 1 and 12, inclusive, representing the month of the year.
MonthName Function: Returns a string indicating the specified month.
MsgBox Function: Displays a message in a dialog box, waits for the user to click a button, and returns a value indicating which button the user clicked.
Now Function: Returns the current date and time according to the setting of your computer's system date and time.
Oct Function: Returns a string representing the octal value of a number.
Replace Function: Returns a string in which a specified substring has been replaced with another substring a specified number of times.
RGB Function: Returns a whole number representing an RGB color value.
Right Function: Returns a specified number of characters from the right side of a string.
Rnd Function: Returns a random number.
Round Function: Returns a number rounded to a specified number of decimal places.
RTrim Function: Returns a copy of a string without trailing spaces.
ScriptEngine Function: Returns a string representing the scripting language in use.
ScriptEngineBuildVersion Function: Returns the build version number of the scripting engine in use.
ScriptEngineMajorVersion Function: Returns the major version number of the scripting engine in use.
ScriptEngineMinorVersion Function: Returns the minor version number of the scripting engine in use.
Second Function: Returns a whole number between 0 and 59, inclusive, representing the second of the minute.
SetLocale Function: Sets the global locale and returns the previous locale.
Sgn Function: Returns an integer indicating the sign of a number.
Sin Function: Returns the sine of an angle.
Space Function: Returns a string consisting of the specified number of spaces.
Split Function: Returns a zero-based, one-dimensional array containing a specified number of substrings.
Sqr Function: Returns the square root of a number.
StrComp Function: Returns a value indicating the result of a string comparison.
String Function: Returns a repeating character string of the length specified.
StrReverse Function: Returns a string in which the character order of a specified string is reversed.
Tan Function: Returns the tangent of an angle.
Time Function: Returns a Variant of subtype Date indicating the current system time.
Timer Function: Returns the number of seconds that have elapsed since 12:00 AM (midnight).
TimeSerial Function: Returns a Variant of subtype Date containing the time for a specific hour, minute, and second.
TimeValue Function: Returns a Variant of subtype Date containing the time.
Trim Function: Returns a copy of a string without leading or trailing spaces.
TypeName Function: Returns a string that provides Variant subtype information about a variable.
UBound Function: Returns the largest available subscript for the indicated dimension of an array.
UCase Function: Returns a string that has been converted to uppercase.
VarType Function: Returns a value indicating the subtype of a variable.
Weekday Function: Returns a whole number representing the day of the week.
WeekdayName Function: Returns a string indicating the specified day of the week.
Year Function: Returns a whole number representing the year.




QTP VB Script Built-in Functions


Types of VBScript Functions
o Conversions (25)
o Dates/Times (19)
o Formatting Strings (4)
o Input/Output (3)
o Math (9)
o Miscellaneous (3)
o Rounding (5)
o Strings (30)
o Variants (8)


Important Functions

1) Abs Function
Returns the absolute value of a number.
Dim num
num=abs(-50.33)
msgbox num

2) Array Function
Returns a variant containing an Array
Dim A
A=Array("hyderabad","chennai","mumbai")
msgbox A(0)
ReDim A(5)
A(4)="nellore"
msgbox A(4)

3) Asc Function
Returns the ANSI character code corresponding to the first letter in a string.
Dim num
num=Asc("A")
msgbox num

* It returns the value 65 *

4) Chr Function
Returns the character associated with the specified ANSI character code.
Dim char
Char=Chr(65)
msgbox char

* It returns A *

5) CInt Function
Returns an expression that has been converted to a Variant of subtype Integer.
Dim num
num=123.45
myInt=CInt(num)
msgbox MyInt

6) Date Function

Returns the Current System Date.

Dim mydate
mydate=Date
msgbox mydate

7) Day Function


Ex1) Dim myday
myday=Day("17,December,2009")
msgbox myday

Ex2) Dim myday
mydate=date
myday=Day(Mydate)
msgbox myday

8) DateDiff Function
Returns the number of intervals between two dates. 
Dim myday
mydate=#02-17-2009#
x=Datediff("d",mydate,Now)
msgbox x

9) Hour Function

Returns a whole number between 0 and 23, inclusive, representing the hour of the day. 
Dim mytime, Myhour
mytime=Now
myhour=hour (mytime)
msgbox myhour

10) Join Function
Returns a string created by joining a number of substrings contained in an array. 
Dim mystring, myarray(3)
myarray(0)="Chandra "
myarray(1)="Mohan "
myarray(2)="Reddy"
mystring=Join(MyArray)
msgbox mystring

11) Eval Function

Evaluates an expression and returns the result.

12) Time Function 
Returns a Variant of subtype Date indicating the current system time.
Dim mytime
mytime=Time
msgbox mytime

13) VarType Function 
Returns a value indicating the subtype of a variable.

Dim MyCheck
MyCheck = VarType(300) ' Returns 2.
Msgbox Mycheck

MyCheck = VarType(#10/19/62#) ' Returns 7.
Msgbox Mycheck

MyCheck = VarType("VBScript") ' Returns 8.
Msgbox Mycheck

14) Left Function

Dim MyString, LeftString
MyString = "VBSCript"
LeftString = Left(MyString, 3) ' LeftString contains "VBS".


14) Right Function


Dim AnyString, MyStr
AnyString = "Hello World" ' Define string.
MyStr = Right(AnyString, 1) ' Returns "d".
MyStr = Right(AnyString, 6) ' Returns " World".
MyStr = Right(AnyString, 20) ' Returns "Hello World".

15) Len Function


Returns the number of characters in a string or the number of bytes required to store a variable. 

Ex 1): Dim Mystring
mystring=Len("G.C.Reddy")
msgbox mystring

Ex 2): Dim Mystring
Mystring=Inputbox("Enter a Value")
Mystring=Len(Mystring)
Msgbox Mystring

16) Mid Function
Returns a specified number of characters from a string.
Dim MyVar
MyVar = Mid("VB Script is fun!", 4, 6) 
Msgbox MyVar

* It Returns ‘Script’ *

17) Timer Function
Returns the number of seconds that have elapsed since 12:00 AM (midnight).

Function myTime(N)
Dim StartTime, EndTime
StartTime = Timer
For I = 1 To N
Next
EndTime = Timer
myTime= EndTime - StartTime
msgbox myTime
End Function 
Call myTime(2000)

17) isNumeric Function


Dim MyVar, MyCheck
MyVar = 53 
MyCheck = IsNumeric(MyVar)
msgbox MyCheck 

MyVar = "459.95" 
MyCheck = IsNumeric(MyVar)
msgbox MyCheck 

MyVar = "45 Help" 
MyCheck = IsNumeric(MyVar) 
msgbox MyCheck 

* It Returns True/False like Result *

18) Inputbox Function
Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns the contents of the text box.

Dim Input
Input = InputBox("Enter your name") 
MsgBox ("You entered: " & Input)

19) Msgbox Function

Displays a message in a dialog box, waits for the user to click a button, and returns a value indicating which button the user clicked.
Dim MyVar
MyVar = MsgBox ("Hello World!", 65, "MsgBox Example")
VBScript syntax rules and guidelines

21.1 Case-sensitivity:


By default, VBScript is not case sensitive and does not differentiate between upper case and lower-case spelling of words, for example, in variables, object and method names, or constants. 

For example, the two statements below are identical in VBScript: 

Browser("Mercury").Page("Find a Flight:").WebList("toDay").Select "31" 
browser("mercury").page("find a flight:").weblist("today").select "31" 

21.2 Text strings:

When we enter a value as a text string, we must add quotation marks before and after the string. For example, in the above segment of script, the names of the Web siteWeb page, and edit box are all text strings surrounded by quotation marks. 

Note that the value 31 is also surrounded by quotation marks, because it is a text string that represents a number and not a numeric value. 

In the following example, only the property name (first argument) is a text string and is in quotation marks. The second argument (the value of the property) is a variable and therefore does not have quotation marks. The third argument (specifying the timeout) is a numeric value, which also does not need quotation marks. 

Browser("Mercury").Page("Find a Flight:").WaitProperty("items count", Total_Items, 2000) 

21.3 Variables:

We can specify variables to store strings, integers, arrays and objects. Using variables helps to make our script more readable and flexible

21.4 Parentheses:


To achieve the desired result and to avoid errors, it is important that we use parentheses () correctly in our statements. 

21.5 Indentation:

We can indent or outdent our script to reflect the logical structure and nesting of the statements. 

21.6 Comments:


We can add comments to our statements using an apostrophe ('), either at the beginning of a separate line, or at the end of a statement. It is recommended that we add comments wherever possible, to make our scripts easier to understand and maintain. 

21.7 Spaces:


We can add extra blank spaces to our script to improve clarity. These spaces are ignored by VBScript.

Errors

We have two types of Errors in VB Script; they are VBScript Run-time Errors and VBScript Syntax Errors

13.1 VBScript Run-time Errors

VBScript run-time errors are errors that result when our VBScript script attempts to perform an action that the system cannot execute. VBScript run-time errors occur while our script is being executed; when variable expressions are being evaluated, and memory is being dynamic allocated.


13.2 VBScript Syntax Errors


VBScript syntax errors are errors that result when the structure of one of our VBScript statements violates one or more of the grammatical rules of the VBScript scripting language. VBScript syntax errors occur during the program compilation stage, before the program has begun to be executed.



Blog Archive

Translate

Popular Posts

Total Pageviews

Blog Archive