RSS Feed

Smart Identification of UFT

Hey, today lets get into this concept of Smart Identification with an example. The QTP help documentation gives a pretty neat explanation of this concept, but you know what … you will understand it better when you first see what it is and then read the help !!! A picture says a 1000 words .. so lets see what this smart identification really is !! You need an example, right ? Ok.. so here we go.

Lets first get prepared. Make sure that your browser has tabbed browsing. In IE8 you go to Tools->Internet Options->General->Tabs->Settings and make sure that you have the check box for “Enable Tabbed Browsing” checked. Next, lets make the home page set to blank. Again .. go to Tools->Internet Options->General->Home Page->Use blank. Lets close Internet Explorer. OK.. we are ready !!

Open QTP and load the Web Add-in. Go to Automation->Record and Run Settings. In the Web tab, make sure that “Record and run test on any open browser” radio button is selected. Now open IE. IE should now be opened and you should be seeing the page about:blank. Go to http://www.google.com. Now lets start recording and hit the Record button in QTP. Now enter site: tpudota.wordpress.com at the search box and click the button “Google Search”. Hope you are with me until now. Stop the recording. If everything went well, this is what you should see in your script..

s1

Lets go to IE and click on the back button. This should take you back to the Google page. Lets run this script now and look at the results.

s2

So far, so good. Now what we will do is close IE and open it once again. Nothing special, just want to get into the reset mode 🙂 So now you have the about:blank page opened again. Go to http://www.google.com again and this time we will open one more tab (not another browser..remember we enabled tab browsing earlier !!) and in this tab also we will go to http://www.google.com. Note that you have your second tab focused and lets leave it like that. Shall we run our script now ? Ok..lets do it !! Lets run our two line test. What happened ? Did it just go to the first tab and execute the test ? What is our results showing ?

s3

Ok…so now we got an example and let me explain from here.
First let us look at a couple of windows
Below is the local object repository

s4

Below is the window you see when you go to Tools->Object Identification

s5

And below is the window you see when you click on the “Configure” button next to the “Enable Smart Identification” checkbox.

s6

In the object identification window, we see that for the browser object, we do not have any mandatory or assistive properties to identify the Browser object. As a result, if you look at the local object repository, you see just the same. So what happened when we created a new tab and went to http://www.google.com and reran the test. QTP saw two browser objects but was unable to decide which browser object it was supposed to go to. Note that the Browser object had the Enable Smart Identification mechanism set to True and so the Smart Identification mechanism kicked in when a conflict aroused.
Now we are going to see what this mechanism actually is. For that we will analyze two windows, the results window of the second test and the window “Smart Identification properties – Browser” as you see on the top. The first part of this mechanism is that QTP will see if there are any Base Filter Properties. Since we dont have any in this case, Smart Identification mechanism moves on to look at the Optional Filter Properties. It will take the first property which is “name” and filter the objects. QTP sees that both the browser objects (both tabs) still had the same value for the name property which is “Google”. Smart Identification mechanism next includes the “title” property as well. QTP still sees that both objects have the same title property value “Google”. Next the Smart Identification mechanism includes the openurl property and tries to filter and now QTP sees that the first tab had the openurl value of “about:blank”. If you noticed, the openurl or the value you see at the address bar when you clicked on the new tab was “about:Tabs”. Since we have now got a unique object, QTP is able to perform the operation and the Smart Identification Mechanism will ignore all the other Optional Filter Properties. Observe above that I have mentioned that “Smart Identification mechanism includes the …. property” . So the previous properties would also be present along with the newly included property for the filtering.
But we didn’t see any name, title or openurl property in the local object repository, right ? Then how did QTP know this ? Try clicking on the + sign in the object repository.

s7

So why was this not shown ? That’s because QTP didn’t need it earlier but now it needed it when it kicked in the Smart Identification AND SO this is one of the main reason that Smart Identification may not be something that you would want to enable !! Oh my God…did I just say that ? Well yes, its because when you enable Smart Identification, you never know which property QTP is going to use to “smartly” detect the object. Your test script could end up entering values in the wrong field or testing the wrong object just because QTP “smartly” identified your object. So though this technique may be considered a good feature in some cases, I have never enabled this to True as it gives me more control on my test because if an object was unable to be identified I would like to know why it was not identified. If I enabled this, I would just ignore the results and assume everything went well. Believe me, I have gone through this a couple of times. However as I have mentioned earlier also, a feature is always good to have. You never know when you will need it.

Hope this example helped you in understanding this concept. Suggestions are always welcome.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: