recording random link part - 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: recording random link part (/Thread-recording-random-link-part) |
recording random link part - logistix - 11-21-2008 Hi, i am using QTP 9.0, in web application i want to test link. When entering Code: Browser("browsername").Page("browserpage").Link("KP (1)").Click RandomNumber(0, 100) i get the link - KP with random number in brackets [for example "KP (219)", "KP (11)"]. But in my case link is also "KP" [without brackets]. And i can not get the right statement for that the link - "KP (1)" "KP(random number)" and also in case "KP" the link CLICKS [/code] RE: recording random link part - rnickerson - 12-13-2008 It's not clear from your message exactly what you are trying to do, but if I understand you have a page that contains 101 links that all have the format: KP(n) Where n is a number from 0 to 100. You are then trying to randomly select and click on one of those links. If this is an accurate description of your issue then you can solve it with some Descriptive Programming: Code: Browser("browsername").Page("browserpage").Link("text:=KP(" & RandomNumber(0, 100) & ")").Click This basically tells QTP to identify a link object with the text value of KP(n), with n being a random number from 0 to 100 and click that link. If there is any other text in the link then this will likely fail. Additionally if there are not 101 links on the page then you run the risk of looking for a link object that does not exist. Plese respond with a more clear description of the issue if this explanation is insufficient. |