Write a Script to Login in to Gmail Account using QTP?

We will write a script to login to a Gmail Account. This QTP Script to log into Gmail Account is a Generic one. There is no need for us to have Object Repository since I am using Descriptive Programming. Where we use the properties and the values to identify the run time object in the Application under test.



We will write a descriptive program to login to Gmail Account. What I am doing is that each of the script contains a line of code to launch Gmail Application and then log into the application

To launch the Gmail application we need to use QTP reserved object like Systemutil or can interact with the Internet Explorer library and launch gmail. After launching the Gmail Application we have the script to login to the account by passing username and password. We will be printing the result at each step to see how the application is behaving

Systemutil.Run "http://www.gmail.com"

Or

'Launching Internet Explorer and Opening Gmail Application
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "http://www.gmail.com"

'We will use the sync method to wait till Gmail opens
Browser("Title:=Gmail.*").Page("title:=Gmail.*").Sync

'Script to set username and password to login
Browser("Title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=Email").Set "xxxxxx"
Browser("Title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=Passwd").Set "yyyyyy"
Browser("Title:=Gmail.*").Page("title:=Gmail.*").WebButton("name:=Sign in").click
Browser("Title:=Gmail.*").Page("title:=Gmail.*").Sync
If Browser("Title:=Gmail.*").Page("title:=Gmail.*").Link("innertext:=Sign out", "html id:=:.*").Exist(1) Then

'Print a Pass message for the user if logged in
Print "User " &Username& " is successfully Logged in"
Else If not Browser("Title:=Gmail.*").Page("title:=Gmail.*").Link("innertext:=Sign out", "html id:=:.*").Exist(1) Then

'Print a Fail message for the user if not able to log in and terminate the action
Print "User " &Username& " is not able to Login in"
Print "The Test has been terminated"
ExitAction
End If
End If

22 comments:

Anonymous said...

the script is written in which language??

and what i have to do in order to use this....

Thanks and Regards

Anonymous said...

It is VBS language,save it as "anything.vbs" Ithink...

Anonymous said...

hh

Anonymous said...

how can we write the above gmail login script using Data driven?

madhu said...

gmail login script using data driven


Set xl= createobject("Excel.Application")

Set wb = xl.Workbooks.Open ("D:\gmaillogin")

Set os = xl.Sheets("Sheet1")


nrc = os.usedrange.rows.count

For i = 1 to nrc

uname = os.cells(i,1)
pwd = os.cells(i,2)

systemutil.Run "iexplore","http://gmail.com"

Browser("name:=Gmail: Email from Google").page("title:=Gmail: Email from Google").webedit("name:=Email").set(uname)

Browser("name:=Gmail: Email from Google").page("title:=Gmail: Email from Google").webedit("name:=Passwd").set(pwd)

Browser("name:=Gmail: Email from Google").page("title:=Gmail: Email from Google").webbutton("name:=Sign in").Click

wait(2)

If Browser("CreationTime:=0").Exist then
browser("creationtime:=0").Close
end if
Next

Unknown said...
This comment has been removed by the author.
Anonymous said...

Thanks for the one who created it, a layman who doesn't know about QTP also can understand what is QTP.

Anonymous said...

How can I do this using perl?

Anonymous said...

Gr8 job
Thanx 4 the script...

Anonymous said...

Please give some more helpful examples like the above one

Anonymous said...

excellent work, easy to understand

Anonymous said...

Using descriptive Prog. how can I write login script for all combination of valid and invalid username,password and how can i generate a report for the passed and failed test. Can you shoa an example for that.

Vishvjeet said...

Great job

sharery dair said...

even when you use SSL. Mike Perry's Bugtraq posting from over half a year ago explains it well. gmail.com sign in

Unknown said...

I have a great fun reading your blogs.Thank you for making this beautiful and awesome blogs. Hope to read more post from you in the future. Please dont forget to visit me in my site @ www.imarksweb.org. Thank you.

Anonymous said...

write script to login excelent pposts..

informatica online training in hyderabad




Unknown said...
This comment has been removed by the author.
Unknown said...

Hi,
Well explained about Write a Script to Login in to Gmail Account using QTP. Can you explain about What are the types object Repositories in QTP?
Thanks,
David,
QTP Developer

laxmi said...
This comment has been removed by the author.
laxmi said...
This comment has been removed by the author.
Himachal News Network said...

When you're 90 years old, what will matter most to you?ThingsyoudoforbeautyDo you serve money or does money serve you?INDIA'S BEST OFF SITE SEO PROVIDER CHEAPEST AND FASTEST OFF SITE SEO SERVICE IN INDIA infocompanion educatijhn

ram said...

Coach require authority a. Attack mission through race west guess.religious

Post a Comment

/* Tynt Insight tracker ----------------------------------------------- */