Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recognition of JavaButton and WebButton
#1
Solved: 10 Years, 9 Months, 1 Week ago
Hello All,

Previously I was working on a Web Application. In that application, in some pages there were more than 1 WebButtons present having the same name, say for example "Save".

On that case, I was using both the "name" and "index" property like
Quote:Browser("").Page("").WebButton("name:=Save","index:=0").Click

QTP used to search all the WebButtons having name "Save" and then from the list of the found WebButtons, it was clicking the WebButton whose index was 0.

Now I am working on a Java Application. In this application, in a window, there are two JavaButtons with two different "Tagname", say "Button1" and "Button2"

When I am using the below code, it is saying that "there are more than one objects satisfying the criteria" (not exactelly the same warning, but conveys the same message)

Quote:JavaWindow("").JavaButton("tagname:=Button1").Click
JavaWindow("").JavaButton("tagname:=Button2").Click

Tagname property for both the buttons has different value, so it should get identified easily (If we look on Web App perspective)

When I am using the following code, the buttons are getting identified

Quote:JavaWindow("").JavaButton("tagname:=Button1","index:=0").Click
JavaWindow("").JavaButton("tagname:=Button2","index:=1).Click

So my point is here, is there any way of identifying the JavaButtons which are unique by its tagname or label in a particular window without using "index" property ?

I mean how do you guys do this ?
Reply
#2
Solved: 10 Years, 9 Months, 1 Week ago
Hi Prabhat ,

I don't think so its a good idea to identify objects using there Tag names.
Let's take your scenario , suppose if i add another Java button into your application with name say "Button1" we have two Java buttons with the same name in that case your script fails because there is no additional property mentioned to uniquely identify the object hence it becomes ambiguous for QTP to understand what has to be done and on what object , so u have to use a property which is unique across objects and index is one among them. And the reason why you are getting this error "there are more than one objects satisfying the criteria" might be because QTP is intelligent enough to identify that the object property you have mentioned is not going to be unique for a long time , i am not sure of the exact cause though. Let's wait for others comments.
Reply
#3
Solved: 10 Years, 9 Months, 1 Week ago
Hi Prabhat,

I agree with the comments posted by Balaji & I think as per my knowledge its not a good practise to identify the Object by using the Tag name. The way you are follwoing for identifying the objects by using Index value is one of the best practise.

Thanks,
Ram
Reply
#4
Solved: 10 Years, 9 Months, 1 Week ago
Hi Ram & Balaji,

But problem in my application is the "index" value is not according to the position of the object.For example there are two Buttons B1 and B2 in the same page. B1 appears much before B2 in the page. So generally what we expect is "index" of B1 should be a smaller number than that of B2. But here everything is unexpected. So it is creating a problem identifying "index" of objects while scripting.
Reply
#5
Solved: 10 Years, 9 Months, 1 Week ago
Hi Prabhat.

Try using the "Location" Property as an ordinal identifier and check whether you can differentiate the objects...

Regards,
Balaji
Reply
#6
Solved: 10 Years, 9 Months, 1 Week ago
Hi All,

I have managed to find a solution for this.

For JavaEdit,JavaList etc. I used the "attached text" property and for JavaButton I used "label" property and it worked perfectly. It now does not require any Ordinal Property like "index" or "location".

I thank all of you for your concern.
Reply
#7
Solved: 10 Years, 9 Months, 1 Week ago
Hi Prabhat ,

Good that the issue is resolved , but make sure that these properties remain static throughout the lifecycle of your application , inducing any other objects with the same label or text will lead to further maintenence of your scripts :-)

Regards,
Balaji
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems with Text color recognition Treirk 0 983 06-17-2019, 12:19 PM
Last Post: Treirk
  Not able to click on webbutton Zalavadia86 3 2,147 10-24-2016, 11:32 PM
Last Post: frebuffi
  object recognition issue by qtp 11.0 shipu 1 2,411 07-24-2014, 05:57 PM
Last Post: Ankesh
  QTP 11 and VB Object Recognition LauraShadle 0 1,854 06-10-2013, 08:27 PM
Last Post: LauraShadle
  Cannot find the "[ WebButton ]" object's parent "[ Page ]" (class Page) sumitparolkar@gmail.com 4 4,774 05-03-2013, 11:53 PM
Last Post: agarwl.anurag

Forum Jump:


Users browsing this thread: 3 Guest(s)