Sunday, April 27, 2008

QTP Regular Expression Example 3

1. Open QTP and a new test.

2. Open Internet Explorer and open this URL http://www.worldtimeserver.com/current_time_in_IN.aspx

3. Click on Record in order to start recording.

4. Go to Insert-> Checkpoint->Text Checkpoint.

5. QTP will be minimized and mouse pointer will change into hand shape.

6. Click on time as shown in below screenshot.

7. Text Checkpoint Properties window will open with the text on which we clicked on, in red color.

8. On the right hand side of 'Parameters' radio button, click on that pen and paper icon, to open Parameter Options dialog box.

9. Make sure Parameters Type is Data Table. In the Advanced Configuration area click on Regular Expression checkbox. Click Ok. Again click ok to come out of Text Checkpoint Properties window.

10. Click Stop in order to stop recording.

In the expert view it will write this code:

Browser("India current local time").Page("India current local time").Check CheckPoint("India current local time from WorldTimeServer.com")

In the global data sheet it will add a new column heading "India_current_local_timeChecked_Text" and will add in the first row- the current time. Now in place of this current time enter this (1[012]|[1-9]):[0-5][0-9] (am|pm) and save it.

Run the test. It should work fine.