Recognition of JavaButton and WebButton - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: Recognition of JavaButton and WebButton (/Thread-Recognition-of-JavaButton-and-WebButton) |
Recognition of JavaButton and WebButton - PrabhatN - 08-20-2010 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 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 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 ? RE: Recognition of JavaButton and WebButton - balaji4u - 08-23-2010 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. RE: Recognition of JavaButton and WebButton - Ram2009 - 08-23-2010 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 RE: Recognition of JavaButton and WebButton - PrabhatN - 08-26-2010 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. RE: Recognition of JavaButton and WebButton - balaji4u - 08-27-2010 Hi Prabhat. Try using the "Location" Property as an ordinal identifier and check whether you can differentiate the objects... Regards, Balaji RE: Recognition of JavaButton and WebButton - PrabhatN - 08-27-2010 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. RE: Recognition of JavaButton and WebButton - balaji4u - 08-30-2010 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 |