Home

Wednesday, August 15, 2012

QTP Challenge

Earlier, This blog post was supposed to explain how QTP identifies the objects but when, for curiosity, I typed in Google, I found 352 and more sites explaining the same. Some of them are so good that I didn’t find it useful to explain the same thing once again. It seems everybody knows how QTP identifies the objects. Still, if you have any concerned question, let me know by posting your questions in comment section.

So, when the initial idea was dropped, I thought to put a challenge on Object Identification by QTP. The challenge is very simple or at least it seems very simple but none of the QTP engineers I know could tell me the correct answer. This might be due to multiple reasons like:

  • They were too busy with their other daily work challenges
  • They didn’t find the challenge interesting enough
  • They didn’t want to spend time on something irrelevant of their daily work
  • They didn’t have tendency to explore about the new things
  • They didn’t have enough courage to take the challenges
  • etc. 

If anyone of you have one of the same reasons, this post is not for you. You can leave the post here and can continue working on something else. Rest of you, please continue with the challenge given below.

Challenge:

Their is a login page which have two fields: Login and Password. I have made some small changes in the code so that both objects have the same properties. Once, it is done I have added both these objects in the object repository and set the same properties for both of them. Now, the situation is:

  • Both of the objects have the same properties (except Logical Name which is not required for object identification)
  • Ordinal Identifier is set to none
  • Smart Identification is also disabled

Now, when I highlight, the QTP identifies the object correctly. The question here is how QTP is recognizing the objects correctly when every property of the two objects are same. Shouldn’t QTP display an error of existing of more than one object with same properties.

Download the Login Page and Object Repository for the reference.

Let me and others know if you have the answer or Please explore if you want to find out the answer yourself otherwise wait till someone post the correct answer. Please post your questions and answers as comments to this post.

(Credits to http://www.authpro.com/ for the login page)

10 comments:

Anonymous said...

what is the answer for this question?

Mohit said...

Anonymous,

Suggest you to try to find the answer yourself and let us know your findings. It will help you to learn something about QTP

If still you couldn't find it, I will answer your question but first try yourself.

Mohit said...
This comment has been removed by the author.
Anonymous said...

I found that QTP is throwing an error as both of the objects having unique description.Its not able to identify the objects correctly.

Anonymous said...

It works with your OR but when I tried to create a new OR with same properties it threw error. there is something magical in your OR that is differentiating these two objects. Whats that? tried so many times but couldnt find.
please tell the answer.

Anonymous said...

not able to identify the objects. Its trowing an error. Could you please let us know whatis the solution?

Anonymous said...

Its throwing an error, Could you please let us know what is the solution?

Mohit said...

Dear Anonymous,

First, apologies for late response, for some reasons I missed your comments.

Second, Thanks for accepting the challenge. I could understand that you really got involved with this to solve the puzzle.

Now, there is nothing magical about this OR. It's just a simple OR. I would suggest you to export this OR in to xml format, you might unwrap the secret.

Btw, which QTP version you are using?

Last request, please publish your name.

Regards,
Mohit Verma

Nakul Gupta said...

Thanks Mohit for replying..

My previous comment was
"It works with your OR but when I tried to create a new OR with same properties it threw error. there is something magical in your OR that is differentiating these two objects. Whats that? tried so many times but couldnt find.
please tell the answer."

As you asked to do, I exported OR in xml format and I could see "source_index" property is diff for both fields( it is 31 and 36). Also this is hidden so cant be seen in OR.

Is it the correct answer? Please let me know..
Thanks Again!
Looking for a new challange and a new lesson
- Nakul Gupta

Mohit said...

Hi Nakul,

This is correct. There is one more difference - the xpath of both the controls are different.

I am happy that you really put the efforts to crack the mystery. Keep the good work continue :)

Regards,
Mohit Verma