Thursday, July 24, 2014

UFT/QTP does not identify an Object

Here are some things to Try when UFT is not recognising objects

1. Open QTP/UFT first

While testing on any app, make sure QTP is opened first and then your application. QTP works by looking into your application. If you open QTP after your application has started there are chances that QTP may not be able to identify objects

2. Load Relavant Add-ins

Make sure you have loaded ALL the relevant add-ins required for your Application Under Test (AUT).

3. Record and Run Settings

While working on web based applications, make sure Record and run test on any open browser is selected under Record > Record and run settings.

4. BHO (Browser Helper Object
) Manager
Make sure BHO Manager in IE under Tools > Manage Add-Ons > Enable or Disable Addons is enabled.

5. Enable Extensions

If you are working on Firefox or Google chrome browser, don’t forget to enable browser extensions.
In case of Firefox go to Firefox menu > Add-ons > Extensions and enable Unified Functional Testing Extension .
For Chrome go to Tools > Extensions and enable Unified Functional Testing Agent.

6. Disable Protected Mode

In IE, clear the Enable Protected Mode option under Tools > Internet Options > Security

7. User Account Control

UAC was introduced in Windows Vista and continued in Win 7 and Win 8/8.1. UAC can interfere with your application. It is a good idea to disable it while working on QTP.
  • To turn-off UAC in Windows 7, go to Start Menu > Search for “Change User Account Settings” > Disable UAC
  • To turn-off UAC in Windows 8/8.1, you need to take help of registry. UI setting doesn’t truly turns-off UAC in Win 8/8.1. Hit Win + R key, type regedit and click OK. Navigate toHKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\SystemFind the key: EbableLUA and change the Value Data value to 0
8. Zoom Level
Make sure the zoom level is set to 100% while testing in any browser. Check the illustration below on how zoom-level affects highlight object functionality in QTP. (Focus on the blinking black rectangle on the left once the Highlight button is clicked on the right.)

9. Object Notation
There are times when identification properties are not enough to identify an object. You may make use of native properties in that case. Use .object notation to locate the erring property. Make sure to correctly identify it.

10. Low Level Recording (click here for different recording modes in QTP)
After you have exhausted all options you can try Low level recording. It’s not a good method from maintenance point of view but it may come handy at times.

11. If your QTP worked well for some days or months and suddenly stopped identifying objects, that has happened probably there is some change in your browser or UFT software itself. Try to disable auto-updates on machines where QTP is installed.

12. If you’re testing cross browser, don’t use Type property to identify Webbutton class since the default value is different for IE (button) and Firefox (Submit).

13. If QTP was successfully able to identify object at record time but unable to identify the same object during replay time, there are chances that object properties are dynamic in nature. Make use of regular expression or parameterization to handle those dynamic values.

14. Make sure the version of QTP you use supports the version of your browser and/or your Windows operating system.

Also read, How to handle dynamically changing objects in UFT?

How to associate Function Libraries to test in QTP/UFT??

When you are creating QTP/UFT scripts or designing any Framework, you will need to associate Function Libraries to them. This can be done Manually or even through scripting.

Here I would like to show you both the ways of Associating a Function Library. The Association can be made in 4 ways.
  1. Using File-> Settings
  2. Using AOM
  3. Using ExecuteFile method
  4. Using LoadFunctionLibrary method

1. Using File->Settings

This is the common and manual method of associating the Function Library. Find below the step by step procedure of doing it

  1. After opening the Test, click on File menu
  2. Click on Settings under file menu. You can see a Window open with name Test Settings
  3. Here, click on the Resources on the left tab. You will see a new Frame in right showing Resources and a empty box below
  4. Here we can click on the plus (+) button and browse and select the function library we need to associate.
  5. After adding the libraries, click on Apply and OK.

2. Using AOM

AOM means Automation Object Model. This is a mechanism using which one can control various operations from outside the QTP. Using AOM, we can even write a code to open QTP test and associate Library Function.

    AOM to open QTP test
        'Open QTP
     Set objQTP = CreateObject("QuickTest.Application")
     objQTP.Visible = True
     'Open a test and associate a function library to the test
     objQTP.Open "C:AutomationSampleTest", False, False     

    AOM to associate a library

        Set objLib = objQTP.Test.Settings.Resources.Libraries
    'If the library is not already associated with the test case, associate it..
    'If library is not already added
    If objLib.Find("C:SampleFunctionLibrary.vbs") = -1 Then 
        'Associate library to test case
        objLib.Add "C:SampleFunctionLibrary.vbs", 1 

3. Using ExecuteFile method

ExecuteFile statement executes all the VBScript statements present in the specified file, thus making all the functions, sub-routines and other elements available to the action as globally. This is how to use the ExecutionFile method:

'Action begins
     ExecuteFile "C:YourFunctionLibrary.vbs" 

4. Using LoadFunctionLibrary

LoadFunctionLibrary is a new method which was introduced in QTP 11, which would allow us to load a function library when the step runs. We can load multiple function libraries in a single line using a comma delimeter. This is how to use the LoadFunctionLibrary method:

     'Associate a single function library
    LoadFunctionLibrary "C:YourFunctionLibrary_1.vbs" 
    'Associate more than 1 function libraries
    LoadFunctionLibrary "C:FuncLib_1.vbs", "C:FuncLib_2.vbs" 

Saturday, June 28, 2014

Facing problem in UFT 11.5 with Find (Ctrl + F) and breakpoints ??

Are you facing problems to perform "Find (Ctrl + F)" operation and adding "Breakpoint" in UFT ??
Unified Functional Tester will not support these 2 operations for the .vbs and .qfl files. It is supported only to the Tests.

So how to perform these 2 operations in your library files ?

Here is the solution for it.

Associate the library function to the Test or Action. by doing this, we can perform Find and Breakpoint operations.

How to Associate file :
1. Open the library file, right click on the tab of the library file and click on "Associate Function Library With"

2. Go to File -> Settings
Select Resources in the Test Settings Dialog and add the Resources by clicking on the "+" button