Micro Focus QTP (UFT) Forums
how to perfom actions on a object if it doesnt have unique property value - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: General (https://www.learnqtp.com/forums/Forum-General)
+--- Forum: Posting Guidelines/Disclaimer (https://www.learnqtp.com/forums/Forum-Posting-Guidelines-Disclaimer)
+--- Thread: how to perfom actions on a object if it doesnt have unique property value (/Thread-how-to-perfom-actions-on-a-object-if-it-doesnt-have-unique-property-value)



how to perfom actions on a object if it doesnt have unique property value - prajeshtt - 12-04-2011

One of my project scenario, below I am explaining the scenario with Yatra.com site.
in one of the booking page, i need to book a desired flight Here the issue is "Book Now" button . In the page there are 10-15 Book Now button with same property values-> there is no unique property value for this "Book Now" buton, here how to click appropriate "Book Now"button, means selecting the desired flight.....in terms of using qtp


RE: how to perfom actions on a object if it doesnt have unique property value - ravi.gajul - 12-04-2011

Get the childobjects of type button and click accordingly based on the index

for ex
Code:
set allButtons=browser().Page().childobjects(<button type>)
for i=0 to allButtons.length-1
allButtons(i).click
next
If you want to click one button then get the i value and click accordingly.
Hope this helps


RE: how to perfom actions on a object if it doesnt have unique property value - prajeshtt - 12-04-2011

(12-04-2011, 08:40 PM)ravi.gajul Wrote: Get the childobjects of type button and click accordingly based on the index

for ex
Code:
set allButtons=browser().Page().childobjects(<button type>)
for i=0 to allButtons.length-1
allButtons(i).click
next
If you want to click one button then get the i value and click accordingly.
Hope this helps

Hi Ravi,

I agree with your point, this logic will click the button in a sequence how the i value increases..In my above scenario I wanna click book button for the Airline I wish which might in the second postiion...when the next time I run the script my desire airline postion can change...In this case how I will i cllick


RE: how to perfom actions on a object if it doesnt have unique property value - ravi.gajul - 12-05-2011

Well, then you may have to take a user input for index and go a head .
i=inputbox("Enter the index")
However if the neighbouring objects of "Book Now" button doesn't change then you can use visual Relation identifiers available with QTP11.0.For more info on visual relation identifiers see the below thread
https://www.learnqtp.com/new-features-qtp-11-aka-functional-testing-11/