Somehow I'm sure i'm not the first with this problem... but couldn't find related subjects
When I define a page checkpoint, I enter the properties page where I have in "Filter link check" the list of links to be checked. The problem is that our product in under developement and the start of the link keeps changing.
How can I define some kind of global variable to keep the beginning of the link?
In QTP 9.1 (and maybe earlier, but I can't say for sure) you can open the Page Checkpoint Properties and (near the bottom of the screen) click the Filter Link Check button which opens a dialog with all the links listed. You can uncheck any link in this dialog which will exclude it from your checkpoint.
Now your checkpoint should check everything except your changing link, so it should be able to pass.
(from your post, I assume you know all of this already)
Then write a Regular Expression check to test the link's URL separately from the checkpoint. Something like this (most of this is copy/paste from the QTP Help file):
strng = browser().page().link("yourlink").GetROProperty("u rl")
patrn = ".*restoftheurl"
Dim regEx, retVal ' Create variable.
Set regEx = New RegExp ' Create regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = False ' Set case sensitivity.
retVal = regEx.Test(strng) ' Execute the search test.
If retVal Then
Reporter.ReportEvent micPass, "Test yourlink", "yourlink is valid")
Reporter.ReportEvent micFail, "Test yourlink", "yourlink is NOT valid")
You want to set patrn to equal as much of the URL as you can. You say the start of the link keeps changing, so I created a very basic regular expression for that, but my basic RE leaves a lot of room for some junk to pass that really shouldn't.
Maybe a better version would be:
patrn = "http://www\..*restoftheurl"
In this case, it will look for "http://www." followed by zero or more of any characters, followed by "restoftheurl" which should, of course, be the last part of the URL that isn't changing each time.
"The last 10% of any software project will take 90% of the budgeted time. The first 90% will take the other 90%"