Welcome to pickSourcecode.com Login | Register    
pickZy.com
 Home  | search  | games  | General  | C  | C++  | Java  | Php  | Networking  | Visual Basic  | VC++  | Win32  | MFC  | JavaScript  | Jobs  | JavaScript  | Post jobs
QTP - Regular Expression Example       Share
2010-03-11 |  MalathiVanaraj  | Viewed: 10124  |    1

QTP - Regular Expression Example

1. Launch QTP and open a new test.
2. Open Internet Explorer.
[Now we have QTP with a blank test and Google open.]
3. Click on Record in order to start recording.
4. Copy and paste this URL (http://mail.yahoo.com) in the browser's address bar to open Yahoo mail login.
5. Type your user name and password to login to Yahoo mail.
6. When Yahoo mail is open, click on the Inbox link as shown in the screenshot below.[ Note: The Inbox can contain any number of mails. At any given point of time, Inbox(5) means 5 unread mails]
7. Click on Stop in order to stop recording. Then my recorded code looks like this:

 

Browser("Browser").Page("Page").Sync
Browser("Browser").Navigate "https://login.yahoo.com/config/login_verify2?&.src=ym"
Browser("Browser").Page("Yahoo! Mail: The best").WebEdit("login").Set "piyush
Browser("Browser").Page("Yahoo! Mail: The best").WebEdit("passwd").SetSecure "4801a2cbf793b46aad67194b5cbc961c091f"
Browser("Browser").Page("Yahoo! Mail: The best").WebButton("Sign In").Click
Browser("Browser").Page("Yahoo! Mail - piyush@yahoo.com").Link("Inbox (6)").Click


if you check any mail like if I check one mail in my inbox then it will be Inbox(5), then if I run this code it will fail because the link has changed from Inbox(6) to Inbox(5) and shows the below mentioned error.


"Cannot identify the object Inbox(6) (of class Link). Verify that this object`s properties match an object currently displayed in your application."


Now we will change the above code with the help of regular expression so that it will work even if there is only one unread mail.


In QTP go to Resources (menu) ->Object Repository.


Object Repository window will open. Select the object "Inbox(6)". Click on the label Inbox(6) inside Value column and then click on "<=>" button which will appear.

When you click on the button, it will open 'Value Configuration Options' window. On this window click on Regular Expression check box. When you click on checkbox it will show warning . Just click on Yes.

Now in the Constant text box inside the displayed window( what I have entered "Inbox \([5-6]\)" and click Ok and close Object Repository window.

This Regular Expression setting which we have done works for inbox unread mails between 5 and 6 e.g. if your inbox says inbox(5) or inbox(6).

Run the test. It passes for me because I had 5 unread mails in my inbox (inbox(5)).

You can do this setting according to your convenience e.g. [1-5] for unread mails between 1 and 5 and so on.


Comments:





Submit comment's

Type:

User Comment's:

Submitted By:
Name: sudha
Prof: Software
Tech: Php ,C
Send Mail: mail2sudha2



Related topics
There is a 50m long army platoon marching ahead. .? - Puzzle
Mr. Bajaj's mother is an Engineer and another is a Doctor. - puzzle
Three men - Sam, Cam and Laurie - are married to Carrie, Billy and Tina? - Puzzle
There are 3 persons X, Y and Z. On some day, X lent tractors to Y and Z as many as they had. .? - Puzzle
A certain street has 1000 buildings. A sign-maker is contracted to number the houses from 1 to 1000..? - Puzzle
DON T EAT TOO MUCH RICE
List of Different Types of Doctors
How to write cover letters
Great Tips for Great Resume
Old carpenter -Story
COIMBATORE ENGINEERING COLLEGES LIST AND ITS SITES
Job Openings in HAL (Especially disabled people.. there is special quota...)
To Reduce Tension in Our Life
Healthy tips
Keep Walking.....-Health tips

Related References
how to draw hexagon diagram? - objective c
to return the key board
recursively delete subdirectories

Web site contents © Copyright 2007, All rights reserved.
Help | Terms and Conditions | Privacy Policy | About Us