Email Validation Using VB Script In QTP/UFT

While automating test cases and developing QTP/UFT script, I came across a requirement where email validation needs to be performed in Gmail. Once email is triggered during test case execution or completion of test case execution, every time email validation required to be done automatically.

There could be scenario where we need to perform email validation or we need to perform email validation of the contents in the mail. For example, every time when a test case execution completes, suppose a notification email gets triggered to the email id provided. Once email triggered to provided email id then you need to verify whether email has been received or not in inbox.

If email validation is performed manually on each execution of script, it will take lots of time and patient to check each email every time after test case execution completes or during test case execution. Hence, it’s a good practice that instead of verifying email manually, we can automate email validation and complete test case execution faster without any manual intervention.

Please follow the steps mentioned below to automate mail validation in Gmail:

Open Browser:

BrowserPath="C:\Program Files (x86)\Internet Explorer\iexplore.exe"
SystemUtil.Run BrowserPath

Navigate and Login Gmail:

 Browser("MAIL").Page("GMAIL").WebEdit("txtGMEmailid").set "Type your email id"
Browser("MAIL").Page("GMAIL").WebEdit("txtGMPassword").set "Type your email password"
If Browser("MAIL").Page("GMAIL").InsightObject("gMailLogo").Exist then
End If

Validate Mail Subject and Contents:

First spy the subject name that you want to verify. Make sure you are spying the mail subject when it is in unread mode. If you spy the subject in read mode then the next time when subject is in unread mode, object will not be identified while executing.

If Browser("MAIL").Page("GMAIL").WebElement("TestMail").Exist Then
 MsgBox "Mail Received Successfully"
'Here you have clicked on the mail subject and mail has been opened.
'Now you can spy the other objects and add the code that you want to do verification.
If Browser("MAIL").Page("GMAIL").WebElement("ThankYou").Exist Then 
 MsgBox "Mail Verified Successfully" 
 MsgBox "Mail Verification Failed"
 End If
 MsgBox "Mail Is Not Received"
End If

Before executing above script make sure you have added all the required objects in object repository. You can change the name of objects as your wish, I have kept the name for my convenience.

One Response to “Email Validation Using VB Script In QTP/UFT”

  1. Glasslae says:

    , text and illustrations to which

Leave a Reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Classica  –  Enter Security Code