Sunday, April 27, 2008

QTP Regular Expression Example 2

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. In this window, on the right hand side of 'Constant' radio button click on pencil and paper button to open "Constant Value Options" button.

9. Check Regular Expression checkbox and in the value field type:(1[012]|[1-9]):[0-5][0-9] (am|pm) . Click OK. Again click Ok to come out of Text Checkpoint Properties window.

10. Click on Stop in order to stop recording.

It will record only one line in the expert view:

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

Now you can refresh that website so as to see the current time and run this test again. It should pass.