- Make use of regular expression
How to handle properties which are dynamic ?
There is an option to replace the property value with a Repository parameter. In this way you can handle the dynamic values for the properties.
In order to do so you need to select the property you want to parameterize and then Select “”(<#>) button on the right side. You get the window “Repository Parameter”
In order to do so you need to select the property you want to parameterize and then Select “”(<#>) button on the right side. You get the window “Repository Parameter”
The value can be a constant that is the same value as before. If you want you can add regular expressions to it.
Regular expression : It is a way to define the search criteria for the string. You can use special characters such “.”, “*”, “[]” etc to define the same.
Regular expression : It is a way to define the search criteria for the string. You can use special characters such “.”, “*”, “[]” etc to define the same.
For example : If you select “Regular Expression” checkbox and add “.*” to your string. So it will search for an object that has “alt” property starting with text “Google” and can have any number of characters after that.
Second way is to select the parameter from the datatable/Environment/Random Number. You can select the radio button “Parameter” and make appropriate settings.
- Source:
http://www.learnqtp.com/uft-object-identification-tips/
17 Things To Try When UFT Does Not Identify an Object:
QTP First
I have repeated this many times in the past and it is still remains the #1 object identification tip. While testing on any app, make sure QTP is opened first and then your application. QTP works by hooking into your application. If you open QTP after your application has started there are chances that QTP may not be able to identify objects.Load relevant Add-ins
Make sure you have loaded ALL the relevant add-ins required for your Application Under Test (AUT).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.BHO Manager
Make sure BHO Manager in IE under Tools > Manage Add-Ons > Enable or Disable Addons is enabled.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.
QuickTest supports recording tests only on Microsoft Internet Explorer. It supports running tests on the following Web browsers:
➤ Microsoft Internet Explorer
➤ Netscape Browser
➤ Mozilla Firefox
➤ Applications with embedded Microsoft Internet Explorer Web browser controls
Disable Protected Mode
In IE, clear the Enable Protected Mode option under Tools > Internet Options > SecurityUser Account Control(UAC)
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 to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\SystemFind the key: EbableLUA and change the Value Data value to 0
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.)A shortcut key to get back to 100% zoom is Ctrl + 0 (that’s zero).
.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.Low level recording
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.My QTP has worked for ages identifying objects correctly, stopped working since yesterday
If something like 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.Type property for WebButton class
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).Object with dynamic properties
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.Version of Browser and Windows OS
Make sure the version of QTP you use supports the version of your browser and/or your Windows operating system. Check the complete UFT vs browser support matrix and UFT vs Windows support matrix.Pop-up Window not identified?
Check this articleInstall relevant patch
In case your application version is not supported by the version of QTP, keep an eye on various patches that HP comes up with from time to time. Check the complete support matrix of QTP/UFT with various technologies. We strive to keep this up-to-date.Few websites that are usefull for object identification are:
http://www.learnqtp.com/uft-object-identification-tips/
http://www.learnqtp.com/category/object-identification-in-qtp/
http://www.learnqtp.com/understanding-enigmatic-to-and-ro-property/
http://www.learnqtp.com/qtp-unable-to-identify-pop-up-window/
- Webex Trainining notes:
What are Ordinal Identifiers ?
Sometimes
there are series of objects with same class name and properties. Lets us say in
a window there are series of checkboxes with the same set of properties. If we
want to act on those objects we need to uniquely identify them so that QTP will
be able to act on it.
An
Ordinal Identifier assigns a numerical value to the test objects which
indicates its location or order relative to its group. The Ordered value enables
QTP to recognize it uniquely when the inbuilt properties are NOT sufficient to
do so.
There
are 3 Ordinal Identifiers in QTP that can be used in different context:
- Index
- Location
- Creation Time
Index:
An
object appearing first in the page/Window will have a smaller Index value when
compared to another object that comes later in the same page/Window.
The
Value of index for the group of text boxes will be as follows:
Object
Name
|
Index
Value
|
TextBox
1
|
0
|
TextBox
4
|
1
|
TextBox
2
|
2
|
TextBox
5
|
3
|
TextBox
3
|
4
|
TextBox
6
|
5
|
Location:
The
Location property works vertically from top to bottom and from left to right.
Hence for the same case, the value of location for the group of text boxes will
be as follows:
Object
Name
|
Index
Value
|
TextBox
1
|
0
|
TextBox
2
|
1
|
TextBox
3
|
2
|
TextBox
4
|
3
|
TextBox
5
|
4
|
TextBox
6
|
5
|
Creation Time:
The
Creation Time property holds good only for web based application. When we open
2 browser sessions of the same website, QTP will not be able to recognize the
window as both the window will have the same set of properties. Hence we can
use creation time with which QTP will be able to act on the window.
'Will have
CreationTime value = 0
SystemUtil.Run
"iexplore.exe", "http://www.google.com"
'Will have CreationTime value = 1
SystemUtil.Run "iexplore.exe",
"http://www.yahoo.com"
'Will have
CreationTime value = 2
SystemUtil.Run
"iexplore.exe", "http://www.microsoft.com"
'Will have CreationTime value = 3
SystemUtil.Run "iexplore.exe",
"http://www.facebook.com"
Hence
to work on a specific browser, we need to explicitly mention the Creation time
in OR or we can use description of objects which we will see in detail in
descriptive programming section.
'Sync's www.google.com
Browser("creationtime:=" ).Sync
'Gets the
RO text property of www.yahoo.com
Browser("creationtime:=1").GetROProperty("text")
'Highlights microsoft.com
-
5/12/15:
Make sure your objects and respective properties are listed in the object repository before your script.
Even when you record your script, the objects will be stored in Object Repository.
So it is must to have the objects(of web application) stored in object repository, before you run your script on web application.
What are the different ways of identifying objects in a web page?
11/6/2015
- One last option if the QTP/UFT does not recognize object is try using Virtual Object.
Virtual object -- there is seperate post in the same blog.
12/24/2015:
- DOM concept could also be used to identify objects in QTP. Refer DOM blog for the same.
Looks like object identification is based on the source code, so could be more easy for us as developers and testers refer to same source code. And we know to read source code.