Micro Focus QTP (UFT) Forums
Square Bracket Issue - Regular Expression - 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 Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions)
+--- Thread: Square Bracket Issue - Regular Expression (/Thread-Square-Bracket-Issue-Regular-Expression)



Square Bracket Issue - Regular Expression - kapsig431 - 03-29-2012

I'm testing an instance of Salesforce.com and have run into an issue. Our development team is using a numerical indicator inside a hyperlink to let the user know how many of "something" reside on the page that link takes a user to. My example is a link that takes the user to a page that has a list of names on it. The link itself reads: Call List [10]...this means that they have ten records on the call list page. Obviously as we test, that number could change to any value.

My problem is a simple one. Because the link itself has square brackets, I believe QTP won't let me use the regular expression feature on the link object. I've tried every way I know to change the text, innertext, outtertext and name of the object in the OR using the regular expression feature. A few that I've tried:

Call List*
Call List [*]
Call List \[\*\]
Call List [(*)]

...and many other variations.

I've even tried using some other expressions such as \w. No matter what I try, I can't get it to work. Does anyone out there have a suggestion? Usually when I get into a problem like this, it is something simple, but I've been trying to figure it out for hours.

The error I'm receiving: "Cannot identify the object 'LeftNav - Call List...'"

My line of code throwing the error:

Browser("salesforce.com - Unlimited").Page("salesforce.com - Unlimited").Frame("Frame").Link("Left Nav - Call List*").Click

I've attached a screen shot of my OR for anyone who is interested. It couldn't be more simple.
[attachment=955]

Thank you!


RE: Square Bracket Issue - Regular Expression - vIns - 03-29-2012

As you think "Call List*" does not match all the words start with "Call List".

It means zero or more occurrences of that char... Actually it tries to match "Call Lis" or "Call List" or "Call Listt" or "Call Listtt" --> got it?

So what you need to do is "Call List.*" --> this will match all the words start with "Call List"


RE: Square Bracket Issue - Regular Expression - kapsig431 - 03-29-2012

As I thought, it was something very simple. Thank you so much, vIns. This has REALLY helped me. It worked perfectly.