Regular Expressions in HTML Page Checkpoints in QTP version 9.2

Basically I am recording HTML source page checkpoints against a website. Having run my QTP script I go to my test results and drill down to the page checkpoint. It informs me that the "Two HTML sources are not the same". This is fair enough as there is inevitably going to be some dynamic data in the HTML source. When you click on 'Show Diff' it runs up the WDiff exe and you can see the exact lines and code in those lines that are different. OK, so now I make reference of those lines that are different and I go into my recorded HTML source and try putting in wild card regular expressions (.*) with the idea of matching anything with the aim of making my test checkpoint pass. I have tried varied regular expressions to match tags also (like ]*>(.*?))and made sure to assert the 'regular expression' checkbox in the 'Edit HTML Source', however upon re-run it always fails. It appears that the WDiff editor/comparison tool is treating all characters literally and not treating the special characters the way they should be treated. Does the WDiff Editor need to be configured to deal with regular expressions? Or is it that this is an issue in QTP, that it is not treating the HTML Source as a regular expression after asserting the 'regular expression' checkbox?

Questions by Lourance1

Showing Answers 1 - 3 of 3 Answers

I dont think you can use the option to compare HTML source unless your page contains only static data that will never change. The WDiff app will just do a text comparision of the html and flag any and all differences. It will not recognise regular expressions as anythinig other than a difference in the html.

I think the answer is to this problem is to create checkpoints for each individual web element on the web page. This will allow you to enter regular expressions for the values of each individual html tag.

steps i used to do this.

1. record you web page in qtp
2. make sure you are in expert view. (my preference:))
3. Click the tab to show the Active screen
4. Click on the browser("blah").Page("blah") piece of code to display the page you are interested in. This should show you the correct screen in the active screen pane.
5. Right click the active screen on the html element you are interested in
6. Select insert Checkpoint to display the Object Selection- Checkpoint properties.
The web element should be selected in the tree view
7. Click OK to open the Checkpoint properties

The checkpoint properties will show you the html tag you are interested in and its innertext value

8. Click the innertext value. This will put the value into the Configure Value frame next to Constant
9. Click the pencil and paper icon
10. Edit the value to be your regular expression.
11. tick the regular expression box and select NO when it asks about adding a backslash.
12. Click OK to close the Checkpoint properties.

This question was really old but I couldnt find an answer to it anywhere so I decided my solution may prove useful. Thats 4 hours of my life i wont get back:)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions