Pages

Monday, September 13, 2010

QTP Regular Expression Example 2 using checkpoint on web

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.
clip_image003
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] . Click OK. Again click Ok to come out of Text Checkpoint Properties window. NOTE:no spaces before and after while copy pasting the value and if the data is not copied properly it will prompt for adding the “\” it shows that there is something wrong in the given value
Re-check and give the proper value
clip_image006
Click here on the symbol and the window will open
clip_image008
Now enter (1[012]|[1-9]):[0-5][0-9] without spaces before and after the expression select the regular expression check box click on OK
clip_image010
The below screen appears
clip_image012click on OK
The below line of script is generated
Browser("Browser").Page("Current local time in").Check CheckPoint("Current local time in India")
10. Click on Stop in order to stop recording.
It will record only one line in the expert view:
Browser("Browser").Page("Current local time in").Check CheckPoint("Current local time in India")
Now you can refresh that website so as to see the current time and run this test again. It should pass.
Results page is as follows when we click on “run”
clip_image014
For datatable :-
Same as above except choosing the constant chose the datatable option in the 8th step above
And enter (1[012]|[1-9]):[0-5][0-9] (am|pm) in the QT I the datatable.

No comments:

Post a Comment