Micro Focus QTP (UFT) Forums

Full Version: Regular Expression in Desc programming
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have to handle city names using regex

This piece of code works for single word city names
like Boston,Austin

--working for single word city
Code:
Browser("Hotels").Page("Hotels").Link("text:=Hotels in .*").Click

If I have city names with 2 words or with . it blows up.

Norfolk-Virginia Beach
Tampa-St. Petersburg
Bergen-Passaic
Riverside-San Bernardino
Orange county

Please some one help me with this how to write for the above mentioned cities.

Code:
Browser("Hotels").Page("Hotels").Link("text:=Hotels in .*").Click
Above stmt should work, what was the error you are getting
I'm guessing you are getting the "object's description matches more than one of the objects currently displayed in your application" error since you are not using more than one identification properties. Usually, you want to at least include "html tag", then if the text property of "text:=Hotels in .*" matches all of the "Hotels in" links on the page, you have to pick out which one you want to click with the "index" property. This will click the first "Hotels in" link:

Code:
Browser("Hotels").Page("Hotels").Link("html tag:=A", "text:=Hotels in .*", "index:=0").Click
In addition to the previous comment, try this:

Code:
Browser("title=.*").Page("title:=.*").Link("name:=xxxx", "index:=0").Click