Sunday, September 22, 2019

13.3 ChildObjects Method


What is the ChildObjects Method ?

You can use the ChildObjects method to retrieve all objects located inside a specified parent object or only those child objects that fit a certain programmatic description. To retrieve this subset of child objects, you first create a description object, and then you add the set of properties and values that you want your child object collection to match using the Description object.

The objects contained in a window or frame are textbox, combo box and link. The window or frame is the Parent Object and the frame or textbox are the ChildObjects.

Syntax – object.ChildObjects(Description) – Description is required for Mobile ADD In and optional for all others.

Points To Remember

      1. Insight Objects do not support ChildObjects method
      2. Android objects are supported and related properties are supported – class, nativeclass, resourceid, text

1. The following script gets the name of all the links from a page -:

Dim oDesc
Set oDesc = Description.Create
oDesc("micclass").value = "Link"

'Find all the Links
Set obj = Browser("Math Calculator").Page("Math Calculator").ChildObjects(oDesc)

Dim i
'obj.Count value has the number of links in the page

For i = 0 to obj.Count - 1                              
   'get the name of all the links in the page
   x = obj(i).GetROProperty("innerhtml") 
   print x 
Next



2. The following script gets the number of Checkboxes with the HTML tag as INPUT and sets all those checkboxes as ON.

Set MyDescription = Description.Create()
MyDescription("html tag").Value = "INPUT"
MyDescription("type").Value = "checkbox"
Set Checkboxes = Browser("Itinerary").Page("Itinerary").ChildObjects(MyDescription)
NoOfChildObjs = Checkboxes.Count
For Counter=0 to NoOfChildObjs-1
        Checkboxes(Counter).Set "ON"
Next


13.2 CheckProperty Method






Description

Checks whether the actual value of the specified object property matches the specified expected value within the specified timeout.

Syntax

Object.CheckProperty(PropertyName,PropertyValue,[TimeOut])


PropertyName - Required. A String value. The name of the property whose value is checked. The available properties are listed in the description properties page under each test object.


PropertyValue - Required. A Variant.
The expected value against which the actual property value should be checked. You can either use a simple value or you can use a comparison object together with the value to perform more complex comparisons.
Example to Show the implementation of CheckProperty
'The following example uses the CheckProperty method to check whether
'the text "Mercury" is entered in the "Name" edit box.
 
Browser("Nested Lists").Page("Page").WebEdit("Name").Set "Mercury"
Browser("Nested Lists").Page("Page").WebEdit("Name").CheckProperty "value", "Mercury"
TimeOut - Optional. An unsigned long integer value.
The time, in milliseconds, within which UFT should check whether the actual value of the property matches the specified expected value. If no value is specified, UFT uses the time set in the Object Synchronization Timeout option in the Run pane of the Test Settings dialog box.
Default value = 60


Return Type A Boolean value. Returns TRUE if the property achieves the value, and FALSE if the timeout is reached before the property achieves the value.
A TRUE return value reports a Passed step to the run results; a FALSE return value reports a Failed step to the run results.
You can also use comparison objects to perform more complex value comparisons. For example, you can instruct UFT to check whether a specific property value is greater than the specified value.
An example of the syntax required when using a comparison object is: Object.CheckProperty "items count",micGreaterThan(8)
The following comparison objects can be used:
  • micGreaterThan: Greater than; Specifies that UFT checks whether the property value is greater than the specified value.
  • MicLessThan: Less than; Specifies that UFT checks whether the property value is less than the specified value.
  • MicGreaterThanOrEqual: Greater than or equal to; Specifies that UFT checks whether the property value is greater than or equal to the specified value.
  • MicLessThanOrEqual: Less than or equal to; Specifies that UFT checks whether the property value is less than or equal to the specified value.
  • MicNotEqual: Not equal to; Specifies that UFT checks whether the property value is not equal to the specified value.
  • MicRegExpMatch: Regular expression; Specifies that UFT checks whether the property value achieves a regular expression match with the specified value. Regular expressions are case-sensitive and must match exactly. For example, 'E.*h' matches 'Earth' but not 'The Earth' or 'earth'.


When the types of the expected value and actual value do not match, the comparisons are performed as follows (in this order):
  • Empty values: Empty values may be an uninitialized variable or field (which returns TRUE for the IsNull function in VBscript) or initialized to an empty value (which returns TRUE for the IsEmpty function is VBscript). When trying to compare two arguments when at least one is an empty value, the comparison assumes equality for two uninitialized arguments and for two empty arguments. Any other combination is considered unequal.
    For example:
    dim vEmpty
    Object.CheckProperty "text",micNotEqual
    (vEmpty)
    will not wait for the timeout (because the 'text' property value is an empty string and the argument passed to micNotEqual is an empty value and so micNotEqual finds them not equal and returns TRUE).
  • String values: When trying to compare a string value with non-string value, the string value is converted to the non-string type and then compared. If the string value cannot be converted to the non-string type, the comparison assumes the values are not equal.
    For example:
    Object.CheckProperty "text",micGreaterThan(8) will not wait for the timeout if the 'text' property value is '16' (because micGreaterThan finds 16 to be greater than 8 and returns TRUE), but will wait if the 'text' property value is 'a' (because 'a' cannot be converted to a number).
  • Boolean values: When trying to compare a Boolean value with non-boolean value, the non-boolean value is converted to a boolean value and then compared. The conversion method assumes that any integer value other than '0' is TRUE, and that '0' alone is FALSE. If the conversion fails to produce a boolean value (for example, if the value is 'abc'), the comparison result will be FALSE (note that for the WaitProperty method this result would instruct UFT to keep waiting). If the conversion succeeds, the method compares the two boolean values according to the comparison logic.
  • Other value types: When other value types do not match, they are compared under the assumption that different types are not equal (nor greater than or less than each other).



13.1 CaptureBitmap Method





What is the function of CaptureBitmap method?

The function of CaptureBitmap method is to save a screen capture of the mentioned object as .bmp or .png file, with a specified name and at a specified path.


Syntax -: object.CaptureBitmap(FullFileName,[OverrideExisting])

Parameters – 1. FullFileName – Required. A String value.
            1. OverrideExisitng - A boolean value. Default value is False.


Return Type – None

Capture an image to the Results Folder

'The following example uses the CaptureBitmap method to capture
 'a screen shot of the No. of Passengers edit box. The file will
 'automatically be saved to a different folder (the test run
 'results folder) in each test run.

 Browser("Mercury Tours").Page("Find  Flights").WebEdit("numPassengers").CaptureBitmap "edit_4.bmp"
Capture an image to an Absolute Folder Path.

'The following example uses the CaptureBitmap method to capture
 'a screen shot of the No. of Passengers edit box and save the
 'image to an absolute path. Each time the CaptureBitmap statement
 'runs, UFT overwrites the previous image with the new one.

 Browser("Mercury Tours").Page("Find  Flights").WebEdit("numPassengers").CaptureBitmap "C:\ScreenCaps\edit_4.bmp", True

Capture an image and upload it to the Database

'The following example uses the CaptureBitmap method to capture an image, after which the image is
 'uploaded to the database.
 Browser("Browser").Page("The official site for").Image("PURE NEW  ZEALAND").CaptureBitmap ("c:\NewZealand.bmp")
 UploadImageToDataBase ("c:\NewZealand.bmp")



Monday, July 15, 2019

4. GUI TESTS AND ACTIONS-1



GUI TESTS AND ACTIONS-1


Define GUI Tests?

In a GUI Test, it contains calls to actions. By default, it contains a call to a single action but we can have multiple actions and multiple action calls to new or existing actions.


Why do we need actions?

We need actions to manage our tests in a more logical, efficient and modular fashion.

What are the different types of actions?

      1. Reusable actions
      2. Non-Reusable actions
      3. External actions
      4. Nested actions

Describe Reusable Actions?

      1. All actions by default are reusable.
      2. Can be called multiple times by local tests and other tests.
      3. Can be modified only from the parent test.
      4. Can be changed into a non-resuable action.

Describe Non-Reusable Actions?

      1. Can be called only once and in the local test.
      2. Can be copied.
      3. Can be changed into a reusable action from properties.

Describe external actions?

      1. Stored with another test.
      2. Read Only from called test.

Describe Nested actions?

1. Called from another action.

Tuesday, July 2, 2019

12 Parameterization - 1 - Basics


Parameterization Basics

What is a parameter?

A parameter is a variable used to denote or represent data in our tests.

Why do we parameterize?

We do parameterization when we want multiple sets of data to be used for the same set of operations.
Suppose we want to automate an application for Localization Testing. We can use the same code and parameterize the input data for the application steps and import the different data for different language from different data table or excel file for each language.
In another example, we can use parameterization for input values for an application with same set of test data as input data. When we have one application as Web and another as Windows with same business flows.


What do we parameterize?

We use parameterization for the below reasons -:

      1. Checkpoints
      2. Object Properties for a selected step.
      3. Object Properties in the Object Repository.
      4. Operation arguments for a selected step.


What are the different types of Parameterization available in UFT?

The different types of parameterization available in UFT are -:

      1. Test and Action Parameterization.
      2. Data Table Parameterization.
      3. Environment Variable Parameterization.
      4. Random Number Parameterization.

What are the different types of Test Parameterization?

The different types of Test Parameterization are -:

      1. Input Parameterization
      2. Output Parameterization
Both the parameterization information can be added from the related Test Properties Pane.
In the Properties Pane – Parameterization tab we have options to -:

a) Add – Input/Output Parameter
b) Edit – edit information related to added parameters such as Name, Value and Type of parameter.
c) Delete – delete a parameter.
We can use these parameter values to pass to the actions present in the test and also to other tests in the same Solution.


What is Action Parameterization?

The different types of Action Parameterization are -:

        1. Input Parameterization
        2. Output Parameterization
Both the parameterization information can be added from the related Action Properties Pane.
In the Properties Pane – Parameterization tab we have options to -:

a) Add – Input/Output Parameter
b) Edit – edit information related to added parameters such as Name, Value and Type of parameter.
      1. Delete – delete a parameter.


What are the different types of Parameterization through Environment Variables?

The different types of Environment Variables are -:

      1. User-Defined Internal Environment Variables
      2. User-Defined External Environment Variables
      3. In-Built Environment Variables.


User-Defined Internal Environment Variables

In the case of User-Defined Internal Environment Variables we can set up variables from the FILE Menu-Settings option-Environment tab.
We can add the environment variables by giving the name and value of the variable from the above pane.
We can also export the User-Defined Environment variable to an XML file from the menu.


User-Definned External Environment Variables

In the case of User-Defined External Environment variable we can create an external XML file in the format accepted by UFT and import the created XML file to UFT with the options present in the menu. The XML file format should start as -:

<Environment>
<Variable>
<Name>VariableName1<\Name>
<Value>VariableValue1<\Value>
<Description>Variable Description1<\Description>
<\Variable>
<Variable>
<Name>VariableName1<\Name>
<Value>VariableValue1<\Value>
<Description>Variable Description1<\Description>
<\Variable>
<\Environment>


UFT In-Built Environment Variables

There are multiple built-in environment variables in UFT which consist of information related to the test. These are variables such as OS Name and Test Name. We can use these environment variables in our code to check with an IF structure and run the required code.


What is the Data Driver?

Data Driver in UFT is used to quickly parameterize several or all occurrences of a property of a test object, checkpoint property and method argument when they have multiple occurrences of a constant in the action.
Data Driver functions like Find and Replace All in excel.

Tuesday, June 11, 2019

11. Function Definition Generator


Function Definition Generator



What is Function Definition Generator?

Function Definition Generator can be selected from the Design menu drop down for a function library or Action.
It allows us to define functions within an Action or function library. It gives us the basic framework to define a function and also associate it with an existing test object and use it as a default operation.

What are the different sections in the Function Definition Generator?

The different sections in the Function Definition Generator are -:

      1. Function Definition
      2. Arguments
      3. Register
      4. Additional Information
      5. Preview
      6. Insert another Function checkbox


Describe the Function Definition section

This section has 3 parts -:

      1. Name – Where we can give the sub-routine or function its name.
      2. Type – We can select any of the 2 options based on what we want to define a) Function or b) Sub-routine
      3. Scope – It can be public or private

Describe Arguments section

This section has the following parts -:

      1. Add argument button
      2. Delete argument button
      3. Move Up argument button
      4. Move Down argument button
      5. Name of the argument
      6. Pass Mode – a) By Reference b) By Value


Describe Register section

In the register section we can add the function to a test object and also apply the function as the default operation on the test object. It basically uses the RegUserFunc keyword or adds this keyword to the function and registers it automatically to the selected test object when this checkbox is selected.

The different options are -:

      1. Register to a test object checkbox – to register the function to a test object.
      2. Test Object Name- to which the function will be registered.
      3. Object Operation – which this function will work upon
      4. Register as default operation checkbox – to confirm if this function will be the default operation of the selected test object.

Describe Additional information section

The Additional information section allows the developer to add more description and documentation related to the function defined.


Describe the Preview section

The Preview section displays the Structure of the Function as defined in the Function Definition Generator.


Describe the Insert another function definition

This checkbox allows another function to be inserted after the current definition is completed.




10. Function Library – Part 1



Function Library – Part 1



What are Function Libraries?

Apart from UFT test objects, methods and in-built functions we can add user defined functions containing VBScript code for each business functions, sub-routines, statements or scripts which needs to be incorporated in multiple actions or codes.

A function library is a separate VBScript code file which can be saved as a text file and associated with UFT tests.

We cannot use a function library with a test without associating the function library with the test.

How does UFT work with Function Libraries?

      1. Create a function library using VBScript and save it as a .qfl or .vbs or text file.
      2. Associate the required function libraries with the Test.
      3. Only after associating function libraries to the tests we can call the functions, sub-routines by the required actions.
      4. During run time UFT loads all the function libraries, it is associated with, to access the functions.
      5. UFT searches the function from the Associated Function Library list and if there are functions with the same name the first function is selected.
      6. The priority of function libraries are as per the list in the solution explorer.

Using a function library dynamically or without associating

We can do that by using the statement LoadFunctionLibrary statement.

If there is a conflict in the names of a dynamically loaded function library and associated function library then dynamically loaded function library is given priority.


Registering a function as an operation to a test object class

We can register a function as an operation to a test object class using RegisterUserFunc.

By using the keyword RegisterUserFunc in an action or function library to register a function to a test object class. We can use this as a defined operation for that class of object.

Eg -: RegisterUserFunc "WebEdit", "MySet", "MySetFunc", True

WebEdit is the class to which the "MySet"(cannot contain spaces) named operation is getting added with the help of the "MySetFunc" user-defined function.
The True argument at the end of the statement makes the operation its default operation.


Using UnregisterUserFunc

By using UnregisterUserFunc we can unregister a user-defined function that has already been registered with the register function.

Unregistering user-defined methods are important to avoid errors in the normal functioning of built-in UFT methods or test failures.



LoadFunctionLibrary and ExecuteFile statements


For a TEST - In LoadFunctionLibrary the code in the function library is available for the complete run session for the complete test.

For a COMPONENT – The LoadFunctionLibrary the code in the function library is available within the scope of the calling component.

In the case of ExecuteFile statement the code of the file is available only within the calling action or component.

LoadFunctionLibrary enables debugging of code in the function library during run time.

ExecuteFile statement does not allow debugging of code and also while using this statement
and debugging a test or component, the execution marker may not be correctly displayed.

Sunday, June 9, 2019

9. RECORD TOOLBAR


RECORD TOOLBAR




Start a recording session

With this button, we can start a recording session as per the settings in the Record and Run Settings in the Record Menu option.


Pause a recording

We can pause a recording session with this button on the Record toolbar.

Action select drop down

We can select an Action from the action select drop down.


Making calls to actions from the Record Toolbar

We can make calls to actions from the toolbar options. The different calls that we can make are -:
          1. Call to New Action
          2. Call to Existing Action
          3. Call to Copy of Action
          4. Call to Existing API Test/Action

Recording Mode Selection

We can select the recording modes and switch recording modes from the Record toolbar.


Capture button

We can learn about an object or multiple objects in a selected area.
There are 2 options for the Capture button
      1. Capture – a particular object related properties
      2. Capture Area – a particular area of the application where multiple objects are captured.

Object Spy button

We can add the object properties by selecting the object using the Object Spy button.




Object Repository Option

We can open the Object Repository using the Object Repository button from the Record toolbar.


Magnifier Button

Using this button in the Record toolbar we can add Checkpoints and Output values as required.


Synchronization Point button

This allows adding a synchronization point for an object of an application by using the WaitProperty method where it waits for a property of an object to come into existence and the time it waits for is in milliseconds.

8. UFT RECORDING-1


UFT RECORDING-1




Why do we record and run?

      1. To find out if UFT is being able to identify objects.
      2. We can add checkpoints using Record and in Keyword view.
      3. We can opt to add output values.
      4. We can use record and run option to learn about objects.
      5. Capture objects to the object repository using the Capture button.
      6. Change the recording modes while recording.


What are the different types of recording modes?

      1. Normal Recording – Default mode
      2. Analog Recording
      3. Low-Level Mode
      4. Insight Mode
      5. UI Automation Mode
      6. Standard Windows Recording



Describe Normal Recording mode.

Normal recording mode uses the UFTs test object model. Each object is added to the Object Repository with the required properties to identify the objects.


Describe Analog Recording Mode

In Analog recording mode all mouse and keyboard operations with reference to the screen or application window is recorded.
This recording mode used where the object level properties cannot be stored such as Digital Signatures.
The steps are recorded in a separate data file added with the action
It is called from the action by a RunAnalog statement.
It takes more space than normal recording mode.


Describe Low Level Recording Mode

      1. Used when the object or actions on it are not supported by UFT.
      2. Used when the environment is not supported by UFT.
      3. Used when the appearance of objects changes but not the location.
      4. All parent level objects are stored as Windows test objects.
      5. All other objects are stored as WinObject test objects.
      6. Steps recorded by low level mode may not run properly for all steps.
      7. Low level recording mode takes more disk space than normal mode.


Describe Insight Recording Mode

      1. Used to identify objects based on what they look like rather than object properties.
      2. Used in case of technologies not supported by UFT.
      3. Used in case of application running on a remote computer.
      4. UFT stores image of object along with ordinal identifiers for Insight objects and this image is used to identify the object rather than its properties.
      5. Takes more space for the images stored for the objects.

Describe UI Automation Recording .

                           Records the objects in your application as UI Automation objects.





Friday, June 7, 2019

7. Action Templates & Properties - 4




Action Templates & Properties





How to create Action Templates?

      1. Write a text file with comments, function calls and other statements in the same format as in the editor view.
      2. Save the file in the UFT installation folder under \dat\ActionTemplate.mst

All new actions that are created will have the lines incorporated in the above file.



Where are the actions and action call properties displayed?

      1. Action Properties dialog box.
      2. Action Properties pane.





6. GUI Tests Actions & Associated Repositories-3


GUI Tests Actions & Associated Repositories-3




Local Object Repositories - Action

Each action has a local object repository associated with it and it also has the highest priority
while identifying objects from multiple OR. If there are objects of the same name, class and parent hierarchy in multiple OR then the one present in the Local OR will be selected for object identification.


Multiple Associated Object Repositories – Action

Each action can have multiple objects repositories associated with it or multiple actions can have one object repository associated with it.
We can also have multiple objects repositories to be associated with a test by default.


What happens when there is a conflict between the objects in multiple object repositories?

When there are multiple objects with the same name, class and parent hierarchy in the different object repositories then the object is identified by UFT based on the local object repository and after that as per the order in the Associated Repositories Tab.


Associate an object repository dynamically

We can associate object repositories dynamically at runtime to the current action by the RepositoriesCollection object.
There are multiple methods for RepositoriesCollection object which can be used to associate
repositories.



5. GUI Actions – Part 2



GUI Actions – Part 2



Inserting a call

We can insert a call to
          1. New action
          2. Existing action
          3. Copy of an action

Ways in which we can insert a call

                                                  1. From the Design menu option
          1. From the Canvas/Keyword view
          2. Record toolbar

Call to COPY of an Action

      1. the action is copied in its entirety, including checkpoints, parameterization, and the corresponding action tab in the Data Table into the calling test
      2. you can make changes to the copied action, and your changes will not affect nor be affected by any other test
      3. You can insert copies of both reusable and non-reusable actions

Call to an EXISTING Action

      1. Calls to existing actions are read-only in the calling test
      2. can only be modified in the test in which they were created
      3. Enables you to use the same action in several tests and makes it easy to maintain tests
      4. You can make calls to only "Reusable" actions

LoadAndRunAction statement

We can load and call actions dynamically using the LoadAndRunAction statement.
Syntax - LoadAndRunAction(TestPath, ActionName, [Iteration], [Parameters])

TestPath - Type - Variant - absolute path of the action, ALM path or relative path
ActionName - Type - Variant - Name of the action
Iteration - Type - Variant - default value - one iteration or 0
                                                                   alliterations or 1
                                                                   range of iterations 1-7


Commands to Exit Actions

ExitAction – exits the current action regardless of its iteration attributes
ExitActionIteration – exists the current iteration of the action




1. Add-In Manager - Basics - I




Add-In Manager - Basics - I



What is the first dialog box we can come across using UFT?


The first dialog box that we come across when we open UFT is the Add-In Manager dialog box.


Why we should not add all Add-Ins for all our tests?

There are multiple add-ins that we can download and use for our automation testing but we must make sure we add only those add-ins which are required for us for the particular test. As having multiple add-ins which are not required for the test comes in the way of Object Identification during run time.

What are the different Add-Ins present in UFT?

Few examples of Add-Ins present for UFT are -:

          1. Java
          2. .NET
          3. Mobile
          4. PDF
          5. SAP
          6. Visual Basic
          7. WPF

How can we add more add-ins if we need to add a few more apart from Add-In Manager Dialog box?

Steps 1. Go to File Menu
          1. Go to Settings option
          2. Go to Properties tab
          3. Go to Associated Add-In section
          4. Click on Modify button.

Why do we need add-ins ?

Using different add-ins in UFT helps the tool to identify the objects in various environments in a better way.
Different add-ins help to add support for the add-ins object model, add more properties and methods for the particular software environment.

Thursday, June 6, 2019

3. UFT Solution Explorer



UFT Solution Explorer

Define Solution?
A solution is a hierarchical structure of testing documents and other related resources. We can use solutions to better organize our testing documents for comprehensive application testing.

Why do we need the Solution Explorer?
      1. If the AUT is complex it helps us to break down the complex application into multiple modules with each module corresponding to each solution.
      2. If AUT is not complex it helps us to organize all files related to an application under one header.
      3. Helps in better organization of different tests, components and files.


What can we have under a solution?

      1. There can be multiple tests under a solution.
      2. There can be multiple GUI tests under the same solution.
      3. There can be multiple API tests under the same solution.
      4. There can functional libraries under the solution.
      5. Local Object Repositories for each function.
      6. Associated Object Repositories


Wednesday, June 5, 2019

2. UFT Home




HOME SCREEN



What are the main components of the UFT Home screen?


A) MENU BAR
B) Short Cuts to Menu Bar options.
C) Solution Explorer
D) Start Page
E) Output
F) Active Screen
G) Data
H) Breakpoints



A) MENU BAR

      1. File
      2. View
      3. Resources
      4. ALM
      5. Tools
      6. Window
      7. Help


B) Short Cuts to Menu Bar options.

      1. New
      2. Open
      3. Save
      4. Save All
      5. ALM Connection
      6. Upload To StormRunner Functional
      7. Solution Explorer
      8. Toolbox
      9. Properties
      10. Data
      11. Object Spy
      12. Last Run Results
      13. Search Help


C) Solution Explorer


D) Start Page
      1. RECENT TESTS/COMPONENTS
          a) New
          b) Open

      1. What's New

      1. RECENT SOLUTIONS
                                          a) New
                                          b) Open

      1. NEWS FEED
      2. UFT FORUM LINKS
        a. GUI Testing Forum
        b. API Testing Forum
        c. Business Process Testing Forum
        d. Quality and Testing
        e. UFT Help Center
        f. Product Movies
        g. UFT Support
        h. UFT Knowledge Page


E) Output

a) Build
b) Design
c) Clear All Lines
d) Toggle Word Wrap
e) Locate Line Containing this item
f) Find String in Output
g) Options
            1. Match Case
            2. Match Whole Word
            3. Use Regular Expression
h) Save Output to a Text File