Relevant Codes (by Anshoo Arora)

A Test Development Resource for HP QuickTest Professional.

Automating GMail with QTP

by Anshoo Arora on March 18, 2010

GMail Logo

GMail Logo

There are many tutorials that can be found on the Internet that show how QTP methods can be used in everyday test development. However, there are very few lessons available for developers starting in QTP that teach how to automate entire applications, or parts of them. This is such a tutorial and will show how parts of GMail can be automated through QuickTest Professional. GMail is an extremely dynamic UI and always quite challenging to automate successfully. Its dynamic behavior also makes it an excellent candidate to practice QTP with and sharpen your skills. I will try to show a few techniques that can be helpful in automating GMail, and through it, automating any dynamic application that you encounter.

GMail Login

I’m sure everyone who has worked with GMail would have already created this part of the script and chances are that it would have been created as a function. The same has been done here with the help of conditional statements:

Function GMailLogin(sUserName, sPassword)
	GMailLogin = False
 
	With Browser("title:=Gmail.*").Page("micclass:=Page")
		'Check if the UserName field exists
		If .WebEdit("html id:=Email").Exist(0) Then
			.WebEdit("html id:=Email").Set sUserName	'Set UserName
			.WebEdit("html id:=Passwd").SetSecure sPassword	'Set Password
			.WebButton("name:=Sign in").Click		'Click Submit
			.Sync
		End If
 
		'Check for Link Inbox(xyz)
		If .Link("innertext:=Inbox.*").Exist(15) Then GMailLogin = True
	End With
End Function
 
'Usage 1:
MsgBox GMailLogin("yourUserName", "yourPassword")
 
'Usage 2:
If GMailLogin("yourUserName", "yourPassword") = True Then
    'Continue with test
Else
    'Stop
End If

Sign Out of GMail

No tricks here. A simple inline DP or OR statement would accomplish Signing out of GMail:

Browser("title:=Gmail.*").Page("micclass:=Page").Link("innertext:=Sign Out").Click
 
'Update March 15, 2011:  The GMail interface has changed slightly. 
'If the above does not work, please try this:
Browser("title:=Gmail.*").Page("micclass:=Page").Link("innertext:=Sign Out", "class:=gbml1").Click

Get New Email Count

Each automation developer prefers a different approach of retrieving desired values from blocks or text. For each task which requires a value to be retrieved, 3 techniques are demonstrated for the retrieval of expected values: Split, RegExp and Left/Right. But first, we must retrieve the entire string containing the number of Unread emails:

Unread Emails

Unread Emails

Retrieve ‘Inbox (3)’
sLink = Browser("title:=Gmail.*").Page("title:=Gmail.*").Link("innertext:=Inbox.*")_
	.GetROProperty("innertext")

Once the string containing the number of unread e-mails is retrieved, one of the following approaches can be used to produce the same result:

Split
iEmails = Split(sLink, " ")(1) '(3)
iEmails = Replace(iEmails, "(", "") '3)
iEmails = Replace(iEmails, ")", "") '3
Print iEmails
RegExp
Set oRegExp = New RegExp
oRegExp.Pattern = "\d+"
Set oMatches = oRegExp.Execute(sLink) 'oMatches(0) = 3
iEmails = oMatches(0)
Print iEmails
Left, Right
iPosition = InStr(1, sLink, "(")
iEmails = Right(sLink, Len(sLink) - iPosition) '3
iEmails = Left(iEmails, Len(iEmails) - 1)
Print iEmails

Get Total Emails Count

Unlike the scenario above, which retrieved the number of unread e-mails in the AUT, this section shows how the total number of e-mails can be retrieved. Just like the previous scenario, a simple inline DP statement can be used to retrieve the number string that contains the value we are looking for:

Total Emails

Total Emails

Retrieve ’1 – 4 of 4′
sText = Browser("title:=Gmail.*").Page("title:=Gmail.*")_
	.WebElement("innertext:=\d+ - \d+ of \d+", "index:=0").GetROProperty("innertext")

After retrieving the entire string, one of the following approaches can be used to produce the result:

Split
iEmails = Split(sText, "of")(1) ' 4
iEmails = Split(iEmails, " ")(1) '4
Print iEmails
RegExp
Set oRegExp = New RegExp
oRegExp.Global = True
oRegExp.Pattern = "\d+"
Set oMatches = oRegExp.Execute(sText) 'oMatches(oMatches.Count - 1) = 4
iEmails = oMatches(oMatches.Count - 1)
Print iEmails
Left, Right
iLoc_Of = InStr(1, sText, "of")
iTotals = Right(sText, Len(sText) - iLoc_Of - 1)
iTotals = Trim(iTotals)
Print iTotals

Space Used by Emails

One important, and a little complex (in comparison to the above scenarios) one: retrieving the space used by Emails. The process will remain the same, but notice the usage of the wild card character for the WebElement:

Space Used<br />

Space Used

Retrieve ‘You are currently using 0 MB (0%) of your 7430 MB.’
sText = Browser("title:=Gmail.*").Page("title:=Gmail.*")_
	.WebElement("innertext:=You are currently using.*of your.*", "index:=0")_
	.GetROProperty("innertext")

The above inline DP statement will retrieve and store the entire string with sText. Once executed, one of the following methods can be used to retrieve the result:

Split
iSpace = Trim(Split(sText, "You are currently using")(1)) '0 MB (0%) of your 7430 MB.
iSpace = Split(iSpace, " ")(0) '0
Print iSpace
RegExp
Set oRegExp = New RegExp
oRegExp.Pattern = "\d+"
Set oMatches = oRegExp.Execute(sText)
iSpace = oMatches(0)
Print iSpace
Left, Right
iLoc_MB = InStr(1, sText, "MB")
sText = Trim(Left(sText, iLoc_MB - 1)) 'You are currently using xx
iSpace = Right(sText, Len(sText) - InStrRev(sText, " ")) '0
Print iSpace

GMail Auto-Generated Response Message

If you would like to check the existence of any of the messages as shown below, accessing the class of the Element will suffice to retrieve the entire text and verify it against our expected result.

Message Sent
Mark Spam
Send to Trash
Undo Spam

Out of the numerous ways these messages could be checked, I am going to show 2 possible uses with a description object and an inline DP statement.

Inline DP
Browser("title:=Gmail.*").Page("micclass:=Page")_
	.WebElement("class:=vh", "html tag:=TD", "index:=0").GetROProperty("innertext")
Description Object + ChildObjects
Dim oDesc, colObject
 
Set oDesc = Description.Create
oDesc("micclass").Value = "WebElement"
oDesc("class").Value = "vh"
 
Set colObject = Browser("title:=Gmail.*").Page("micclass:=Page").ChildObjects(oDesc)
 
MsgBox colObject(0).GetROProperty("innertext")

Finding Row with Containing Text

To find an e-mail row using text, we can either create a custom function or use the GetRowWithCellText method of the WebTable. However, chances are that the custom function will not prove to be quite as fast. A custom function has been created to find the row containing the specified text:

Custom Function
Function FindMailRow(sText)
	Dim oTable, iRows, ix
 
	FindMailRow = -1
 
	With Browser("title:=Gmail.*").Page("micclass:=Page").WebTable("class:=F cf zt")
		iRows = .GetROProperty("rows")
 
		For ix = 1 to iRows
			sMailText = .GetCellData(ix, 3) & .GetCellData(ix, 5) & .GetCellData(ix, 7)
			If InStr(1, LCase(Replace(sMailText, vbLf, " ")), LCase(sText)) Then
				FindMailRow = ix
				Exit Function
			End If
		Next
	End With
End Function
 
'Usage:
MsgBox FindMailRow("Text")

The outcome will be the same when using the GetRowWithCellText method, but with a smaller performance footprint.

GetRowWithCellText
MsgBox Browser("title:=Gmail.*").Page("micclass:=Page").WebTable("class:=F cf zt")_
    .GetRowWithCellText("Redefining")

The custom function took 2.45 seconds to find the row whereas GetRowWithCellText took only 1.22 seconds.

Reading Emails

The above method can be coupled with a click event to find and open the e-mail that is to be read. A simple inline DP statement can be used to click the target row and open the e-mail. In this example, we’re going to click on the 2nd Email:

'I have used 'Access Gmail' but you can use any (unique) text on that row
iRow = Browser("title:=Gmail.*").Page("micclass:=Page").WebTable("class:=F cf zt")_
    .GetRowWithCellText("Access Gmail")
 
With Browser("title:=Gmail.*").Page("micclass:=Page").WebTable("class:=F cf zt")
	.ChildItem(iRow, 3, "WebElement", 0).Click
End With

When the row is clicked, the Email is opened for reading:

Row 2: Access Gmail

Row 2: Access Gmail

I hope this article provides more in-depth knowledge of testing complex Web applications. I hope to find more such applications in the future to share with everyone. If you feel there is a scenario that this article lacks, or will become more useful with the addition of one, please do let me know.

If you have any questions, please ask them in the comments section. If your query is confidential, please use the Contact Form to send me an e-mail instead.

{ 91 comments… read them below or add one }

1 sunitha March 19, 2010 at 9:01 am

how to handle dynamic object like deleting last email in the page every time?

Reply

2 Anshoo Arora March 19, 2010 at 10:25 pm

Sunitha,

The following code can be used to delete the last received e-mail each time:

With Browser("title:=Gmail.*").Page("micclass:=Page")
	.WebTable("class:=F cf zt").ChildItem(1, 1, "WebCheckBox", 0).Set "ON"
	Setting.WebPackage("ReplayType") = 2
	.WebElement("innertext:=Delete", "index:=0").Click
	Setting.WebPackage("ReplayType") = 1
End With

3 sreenu August 16, 2011 at 6:45 am

HI, the above script is running correctly for the first time.
when i run the sams script for next time it is displaying msg as “webtable objects description matches more than one of the objects in your application.”
once i close gmail and open again the script is running fine for the first time.

what may be the reason.can anybody suggest

4 Manas March 29, 2010 at 3:12 am

Hi Anshoo

When I am opening mercury tours application it is showing

FATAL ERROR: register_globals is disabled in php.ini, please enable it!

What shall i do ??

how can i enable in php.ini ?

Reply

5 Anshoo Arora March 29, 2010 at 12:59 pm

Hi Manas,

I also see the same error.

Please see San’s (below) note on the issue. Thank you, San.

6 San March 29, 2010 at 4:17 am

Hi Manas,

It is not a problem of QTP, even this is a problem of PHP.INI configuration file setting. There is a PHP.INI file on the server, where you have to set this variable enable.

Thanks

Reply

7 Hannah May 7, 2010 at 12:19 am

Hello,

What is the code if you want to read all unread emails in the gmail account one by one.

Thanks,
Hannah

Reply

8 Anshoo Arora May 7, 2010 at 2:26 am

The following code will highlight all the unread conversations:

Set oDesc = Description.Create
oDesc("micclass").Value = "WebElement"
oDesc("class").Value    = "zF"

Set colChild = Page("title:=.*mail.*").ChildObjects(oDesc)

If colChild.Count > 0 Then
	For ix = 0 to colChild.Count - 1
		colChild(ix).Highlight
	Next
End If

Set colChild = Nothing
Set oDesc = Nothing

The following code will click all unread e-mails:

Set oDesc = Description.Create
oDesc("micclass").Value = "WebElement"
oDesc("class").Value    = "zF"

With Page("title:=.*mail.*")
	Set colChild = .ChildObjects(oDesc)

	For ix = 0 to colChild.Count - 1
		colChild(ix).Click
		iy = 0 

		Do
			iy = iy + 1
			Set oDesc = Description.Create
			oDesc("micclass").Value = "WebElement"
			oDesc("class").Value    = "iw"

			Set colChild = Page("title:=.*mail.*").ChildObjects(oDesc)
		Loop Until (colChild.Count > 0) OR (iy = 15)

		If Not colChild.Count > 0 Then Exit For

		.Link("innertext:=Inbox.*", "index:=0").Click

		If Not .WebElement("class:=yX xY", "index:=0").Exist(10) Then Exit For

		Set oDesc = Description.Create
		oDesc("micclass").Value = "WebElement"
		oDesc("class").Value    = "zF"

		Set colChild = .ChildObjects(oDesc)

		If colChild.Count = 0 Then
			Exit For
		End If

		ix = -1
	Next
End With

Set colChild = Nothing
Set oDesc = Nothing

9 Hannah May 7, 2010 at 3:07 am

Hello,

I have a question. Why do I get an error in the clicking of Sign Out. The frame’s value changes:
Frame(“c1nzi95jbotg2z”).Link(“Sign out”).Click

Please advise.

Hannah

Reply

10 Anshoo Arora May 10, 2010 at 10:16 am

Hannah,

In a Web application, you can completely skip the Frame object and refer directly to the child object. In your case then, you can write an inline statement like this:

Browser("").Page("").Link("").Click

However, to answer your question: your observation is absolutely correct. I did notice that Google has dynamic frames that change frequently. I think the best way to handle this would be through a Regular Expression or ChildObjects. However, I would still recommend to avoid the Frame completely and use Browser/Page as the parent in the hierarchy.

11 kishore August 4, 2010 at 2:13 am

Hi Hannah,
Did u find the solution? I am facing the same problem. I tried avoiding the frame part, but it didn’t work.
I tried with the following but not succeded.
1. ‘The frame name starts with c always
Browser(“browserName”).Page(“Pagename”).Frame(“c.*”).Link(“Sign out).click -9999, -9999
2. Browser(“browserName”).Page(“Pagename”).Link(“Sign out).click -9999, -9999

Let me know how to handle this.

Thanks
kishore

12 Anu May 17, 2010 at 4:38 am

Hi Anshoo,

I have web page consist of Data table & many links.
My query is that i want to automate my links.

Reply

13 Anshoo Arora May 18, 2010 at 8:00 am

Anu,

Not sure I understand the question? How do you want to automate these links??

14 lestrada May 17, 2010 at 5:29 pm

Helllo

I am triyng to send a mail throuhg QTP from Gmail.
How do I can write in the field of the body mail, if QTP recognize that object as a WebElement and it doestn allow to set any value?

Thnks
Sorry by my english. I hope you understand to me.

Reply

15 Anshoo Arora May 18, 2010 at 8:11 am

In the inline hierarchy, after the WebElement, insert the following code and see if it works:

.Object.innerText = "test"

16 Satya June 17, 2010 at 1:20 am

this is the best code & coverage ever I got online….
Thanks a Ton…wonderfull…….

Reply

17 Anshoo Arora June 22, 2010 at 12:30 pm

:)

18 Anonymous June 24, 2010 at 3:39 pm

I am glad some to know some one who really meant to help others!!
God Bless you with more knowlege.

Reply

19 michelo June 27, 2010 at 9:59 am

hello all!!!

Do u know how to write a script sending test mail ?

Reply

20 Anshoo Arora June 28, 2010 at 10:38 am
21 kishore August 4, 2010 at 6:04 am

Hi,
I am unable to click on singout button in gmail using qtp. When i record it, it shows as
Browser(“browserName”).Page(“Pagename”).Frame(“c34fas4afa54″).Link(“Sign out”).click

The frame name is dynamic . So while recording it shows one frame name and while executing it shows diffrent framename and it fails. I tried the following but not able to succeed.

1. ”The frame name starts with c always
Browser(“browserName”).Page(“Pagename”).Frame(“c.*”).Link(“Sign out”).click -9999, -9999
2. ”I ignored the frame as some says it is not neccessary

Browser(“browserName”).Page(“Pagename”).Link(“Sign out).click -9999, -9999

In bot the cases, the test is failing as it not able to find the object.

Let me know how to handle this.

Reply

22 Anshoo Arora August 5, 2010 at 2:10 pm

Kishore,

If you want to apply a RegEx to the Frame object, you can do it like this: Click here. You may have to use an Index value as well.

23 srikanth May 15, 2011 at 2:13 am

use this code:

Browser(“title”=Gmail.*”).Page(“title:=Gmail.*).Link(“outertext:=Sign out”).Click

If not, add other properties like html id or class for “Link” class.

It should work

24 Mahesh Upadhyay November 17, 2010 at 8:08 am

Hi Anshoo,

Good Article for Automating Gmail.

Regards
Mahesh

Reply

25 Satish December 8, 2010 at 7:23 am

Hi Anshoo,

This is satish working as a quality engineer in s/w organization..i am purely into manual testing..i have a keen interest to shift into automation side.. i have very basic knowledge in QTP where i am aware of developing very small scripts covered all concepts..can you please guide me how to approach further inorder to gain more knowledge in QTP(from basic to advanced)

If you have any documents/link then please email to satish.btech2210@gmail.com

Thanks in advance,
Satish

Reply

26 anu December 9, 2010 at 2:59 am

how to see emails in gmail which comes i particular date

Reply

27 anu December 9, 2010 at 3:03 am

Hi Anshoo,
please tell how to test emails in gmail which comes in particular date like 09-12-2010

Reply

28 Aruna December 10, 2010 at 10:03 am

Hi Anshoo
Thanks for your great effort to help Qtp learners like me.I tried to automate gmail and yahoo pages but qtp recognises them as winobjects.Please advice me what to do.Relevant codes site is rcognised as a browser but gmail and yahoo are recognised as windows object.Please guide me what to do.

Thanks
Aruna

Reply

29 Anshoo Arora December 19, 2010 at 7:43 pm

Aruna,

Is the Web add-in loaded? Are you using IE, and was IE launched “after” QTP?

30 markQA January 29, 2011 at 12:53 pm

The gmail compose button, I believe due to its custom build, is almost impossible to script. I tried so many different approach, including the one provided in this post. And all of them failed. Arun, I hope you can show me some light on this.

WebElement(“innertext:=Compose Mail”, “html tag:=SPAN”) these with many additional properties unable to detect QTP to select the compose button.

Thanks.

Mark

Reply

31 Anshoo Arora January 29, 2011 at 2:09 pm

Mark: Try this:

Setting.WebPackage("ReplayType") = 2
	Browser("title:=Gmail.*").WebElement("innertext:=Compose Mail", "class:=J-K-I-Jz").Click
Setting.WebPackage("ReplayType") = 1

32 markQA January 29, 2011 at 3:05 pm

Hi Anshoo,

Thanks for prompt reply! And it did the trick!!

Can you please explain theses two lines:

Setting.WebPackage("ReplayType") = 2
Setting.WebPackage("ReplayType") = 1

I did try the

WebElement("innertext:=Compose Mail", "class:=J-K-I-Jz")

before without any luck.

Mark

Reply

33 Anshoo Arora February 10, 2011 at 12:16 pm

Mark,

Changing the replay type changes the way events occur on the AUT. Tarun has written an article about it here: http://knowledgeinbox.com/articles/qtp/settings/when-to-change-qtp-web-replaytype-setting/

34 Anshoo Arora February 19, 2011 at 6:57 am

Mark,

Those 2 statements change the Replay type for Web applications from Browser to Mouse and vice-verse. Tarun has written an article regarding this topic which you can find here.

35 markQA January 29, 2011 at 6:36 pm

Hi Anshoo,

Its me again. I tried to use the same compose button concept you showed me for two other undetectable button/link: Attach a file and Send.

It works fine for Attach, but failed on Send.

Also I am having trouble to script the file attachment Dialog window, several trial & error failed. The details code below:

SystemUtil.Run"iexplore.exe","gmail.com"
Browser("title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=Email").Set "id"
Browser("title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=Passwd").Setsecure "pass"
Browser("title:=Gmail.*").Page("title:=Gmail.*").WebButton("name:=Sign in").click
'mouse click on compose button
Setting.WebPackage("ReplayType") = 2
Browser("title:=Gmail.*").WebElement("innertext:=Compose Mail", "class:=J-K-I-Jz").Click
Setting.WebPackage("ReplayType") = 1
Browser("title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=to").Set "abc@xyz.com"
Browser("title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=subject").Set "Gmail Automation"

Set objEdit= Browser("title:=Gmail.*").Page("title:=Gmail.*").WebElement("html tag:=BODY", "html id:=:.*")
objEdit.Object.innertext="Testing gmail login, compose, file attach, send and sign out by using QTP-DP"

'mouse click on Attach a file
Setting.WebPackage("ReplayType") = 2
Browser("title:=Gmail.*").Page("title:=Gmail.*").WebElement("html tag:=OBJECT","html id:=FLASH_UPLOADER_1").Click
Setting.WebPackage("ReplayType") = 1
Wait(2)
'the following 2 lines are not working
Browser("title:=Gmail.*").Dialog("micClass:=Dialog").WinEdit("attached text:=File &name:").Set "c:\123.txt"
Browser("title:=Gmail.*").Dialog("micClass:=Dialog").WinButton("Open").Click
Wait (5)

'mouse click on Send (its not working)
Setting.WebPackage("ReplayType") = 2
Browser("title:=Gmail.*").Page("title:=Gmail.*").WebElement("innertext:=Send", "class:=J-K-I-Jz").Click
Setting.WebPackage("ReplayType") = 1

Browser("title:=Gmail.*").Page("title:=Gmail.*").Link("innertext:=Sign out", "html id:=:.*").Click
Browser("title:=Gmail.*").CloseAllTabs

I hope you can provide a solution for those two problems. Also would appreciate if you can suggest any script optimization.

BTW, I am learning QTP from earlier this month, and undoubtedly this is one of the best learning site I came across! Keep up the good work.

Regards,

Mark

Reply

36 Anshoo Arora February 19, 2011 at 7:01 am

Mark,

There you go:

With Browser("title:=Gmail.*")
	.Dialog("micClass:=Dialog").WinEdit("attached text:=File &name:", "index:=0").Type "c:\123.txt"
	.Dialog("micClass:=Dialog").WinButton("text:=&Open").Click

	Setting.WebPackage("ReplayType") = 2
		.WebElement("innertext:=Send", "index:=0").Click
	Setting.WebPackage("ReplayType") = 1
End With

37 minu February 2, 2011 at 2:27 am

Hi anshoo,

suppose i want to search MINU in google.com .upto i find this file i have to search…
how to write a script for this…
Can u suggest me some ans.

Thanks

Reply

38 Gaurav Gupta February 4, 2011 at 8:09 am

Hi Anshu,
While executing the below mentioned code on QTP9.2 , it is showing “General Run Error” on line “18″ — “Set ccCount = Browser(“name:=.*”).Page(“Title:=.*”).childobjects(oCheck)”
Please could you help me to resolve the issue

SystemUtil.Run “iexplore.exe” , “www.gmail.com”

Browser(“name:=.*”).Page(“Title:=.*”).WebEdit(“Name:=Email”).set “om.gaurav”
Browser(“name:=.*”).Page(“Title:=.*”).WebEdit(“Name:=Passwd”).Setsecure “”
Browser(“name:=.*”).Page(“Title:=.*”).WebButton(“Value:=Sign in”).click
Browser(“name:=.*”).Page(“Title:=.*”).sync

Set oCheck= Description.Create ()
oCheck(“htmltag”).value = “Input”
oCheck(“type”).value = “checkbox”

MyTotalCheckBox = 0
Looping = “Y”

Do while Looping = “Y”

Set olderlink = Browser(“name:=.*”).Page(“Title:=.*”).link(“Outertext:=Older.*”,”index:=0″)
Set ccCount = Browser(“name:=.*”).Page(“Title:=.*”).childobjects(oCheck)

MyTotalCheckBox = MyTotalCheckBox + ccCount.count

if olderlink.exist(1) Then
Looping = “Y”
olderlink.click
else
Looping = “N”
End if

Loop

Browser(“Name:=.*”).Close
Print “Number of Emails in Your Inbox are” & MyTotalCheckBox

Reply

39 Cosmin February 7, 2011 at 4:16 am

I try to automatize the access to the Gmail index box. The code provided above is working fine for log on on the gmail.
I have problem when i try to access the firs e-mail for example from the inbox. If i try to record the click on the e-mail using QTP 11 the nothing happen (the click in not recognize).
If i try the same but using descriptive approach i receive the error message that the “WebTable” element is not recognized.
If i try to retrieve the name of the “WebTable” using this line: web_table_name1 = browser(“creationtime:=”& icount-1).page(“micclass:=Page”).Frame(“micclass:=Frame”,”index:=0″).WebTable(“micclass:=WebTable”).getroproperty(“name”)
I receive the error that WebElemet is not recognized.

Reply

40 markQA February 9, 2011 at 8:46 pm

Hi Cosmin,

Did you checked my scripts from comment: 47?

http://relevantcodes.com/automating-gmail-with-qtp/#comment-14268

Thanks.

41 payal February 25, 2011 at 5:28 pm

hi Anshoo,

ould you please help me in automating safari and chrome. Is there any way in qtp to automate them?

Thanks in advance!!!!

Reply

42 Amit March 15, 2011 at 9:57 am

I must be missing a very basic thing here:

I am simply trying to log out from GMail, and using

Browser(“title:=Gmail.*”).Page(“micclass:=Page”).Link(“innertext:=Sign Out”).Click

But QTP 11 end up saying : The “[ Link ]” object’s description matches more than one of the objects currently displayed in your application. Add additional properties to the object description in order to uniquely identify the object.

Any suggestions!

Reply

43 Paul March 27, 2011 at 7:00 am

Hi Anshoo,
how did you manage to use index:=0 in the following statement, i mean how do we arrive to using index:=0 for this?
sText = Browser(“title:=Gmail.*”).Page(“title:=Gmail.*”)_
.WebElement(“innertext:=You are currently using.*of your.*”, “index:=0″)_
.GetROProperty(“innertext”)

Thanks

Reply

44 naveen g April 19, 2011 at 1:49 am

Hi Anshoo…….

first of all I say thanks to you……this is very useful to me…….and u have provided very useful informaion on gmail application…….
thank uuuu

Reply

45 Anonymous April 23, 2011 at 10:31 am

Hi Anshoo,

I’m unable to click on ‘Compose Mail’ button, I tried the below code.
Browser(“title:=Gmail.*”).WebElement(“innertext:=Compose Mail”, “class:=J-K-I-Jz”).Click

Regards,
Avinash

Reply

46 ashish May 15, 2011 at 5:43 am

hi
anshoo,
every thing is fine but i have a scenario :
select spam mails and delete all spam mails
how will do that ??

Reply

47 dhiraj June 9, 2011 at 1:57 am

Hi Anshoo,

I have an application in which I v to login and submit at specific time , I v created the script for that, but now my problem is I want run the script at specific time from schedule task, I v script to open QTp automatically through command prompt.
My question 1. I want to open command prompt at specific time.
2. On command prompt I want to call script to launch qtp. (I can enter it manually and it’s running successfully)

Reply

48 Anshoo Arora June 24, 2011 at 10:49 am

Dhiraj: You can create an AOM file that can do it. See here: http://motevich.blogspot.com/2008/04/how-to-run-qtp-test-from-command-line.html

This file can be called from a scheduled task, that will run the test from cmdline.

49 Anonymous July 5, 2011 at 2:34 am

What is the code if you want to read all emails in the gmail account one by one and to copy the sender mail id in to datadable and retrive in to excel

Reply

50 mohan July 5, 2011 at 2:35 am

What is the code if you want to read all unread emails in the gmail account one by one and to copy the sender mail id in to datadable and retrive in to excel

Reply

51 Newbie July 29, 2011 at 5:45 pm

I am trying to use checkpoints to validate data for contacts in the contact page for gmail. But the values are not getting recongised and it also does not recognise contact button or any contacts on the page. I am new to QTP too. Can you please help me out

Reply

52 Anshoo Arora August 1, 2011 at 4:31 pm

Ashy, as sent to your mailbox:

With Browser("title:=Gmail.*")
    .WebElement("html tag:=DIV", "html id:=:ra").WebElement("innertext:=Contacts", "class:=is").Click

    With .WebTable("html id:=:18a")
        If .Exist(5) Then
            iRow = .GetRowWithCellText("John Smith") '<--- insert name of a contact here

            For iCol = 1 To .GetROProperty("cols")
                Print .GetCellData(iRow, iCol)
            Next
        End If
    End With
End With

53 Anu September 26, 2011 at 9:40 am

Is there anyway to automate “validating the content of the opened email item”?

Thanks in Advance…

Currently we are fetching the content of the email using child objects of Frame.

Reply

54 Roselin October 11, 2011 at 12:39 am

Hi,

How to continue the statements in QTP?

i.e.,” HTMLResultMessage objHTMLResultFile,”Check the Request category list items “,”Items ” &strReqCategory1& “, “&strReqCategory2&”, “&strReqCategory3&”, “&strReqCategory4&”, ”
&strReqCategory5&”, “&strReqCategory6&”, “&strReqCategory7&”, “&strReqCategory8&”, “&strReqCategory9&”, “&strReqCategory10&”, “strReqCategory11
&”, “&strReqCategory12&”, “&strReqCategory13&”, “&strReqCategory14&”, “&strReqCategory15&”, “strReqCategory16& ” are present in the list”,”Pass” ”
How to write this code in next line in QTP instead of writing it continously?

Reply

55 Ashish November 30, 2011 at 1:29 am

Hi Anshoo,
Currently i am working in manual testing and want to move from manual testing to QTP automation testing.
Could you please provide me some of the start-up learning document in my email id ashi.gkp@gmail.com ?

Thanks

Reply

56 Sourish Mallick December 14, 2011 at 2:40 am

Hi Anshoo,

I have lotus Domino where it doesnt show the number of mail in inbox or unread mail in inbox.
I want to automate to read the no of mails by fetching the subjects of the mail from inbox.
Could you please give me some idea.
I have tried by WebTable property but its showing the result of the portion that is visible not showing the ones under that.
If you want i can send you the screenshots..

Reply

57 Anshoo Arora December 27, 2011 at 7:28 am

Sourish, you can use ChildObjects to match the properties of the unread mails to retrieve the count.

58 Barani December 23, 2011 at 2:06 am

hi all,
i hv 1 dbt, actually my application sends a confirmation mail or some respond mail to customer personal id or customer company email id. i need to chk both mails. can any one help me out to this issue.. Thanks in advance

Reply

59 Anonymous December 28, 2011 at 9:15 am

Hi Anshoo,

While i try to login to Gmail . I am not able to identify the error : ” The user name and password is incorrect. ? ”

I have used the below script .. When i get the error as Enter the password it is executing the respective loop . But when i get the above error message it is not executing the respective loop

Script

Dim a
Set iobjec=createobject(“Internetexplorer.Application”)
iobjec.visible=true
iobjec.navigate “www.gmail.com”
with Browser(“title:=Gmail: Email from Google”).Page(“title:=Gmail: Email from Google”)
.webedit(“html id:=Email”).set “dfadfdfsafad@gmail.com”
.webedit(“html id:=Passwd”).setsecure crypt.encrypt(“dsfsdfwrewaasd”)
.webbutton(“html id:=signIn”).click
‘ *********************** the below loop works *************
If Browser(“title:=Gmail: Email from Google”).Page(“title:=Gmail: Email from Google”).image(“alt:=Visual verification”).exist Then
Msgbox ” Enter the Visual verification text”
wait(5)
End If
‘ ****************** the below loop also works *************************
If Browser(“title:=Gmail: Email from Google”).Page(“title:=Gmail: Email from Google”).WebElement(“innertext:=Enter your password.”).Exist Then
msgbox (“Incorrect Login”)
.webedit(“html id:=Email”).set “qtpt@gmail.com”
.webedit(“html id:=Passwd”).setsecure crypt.encrypt(“dgdfsdfsdsds”)
wait(2)
.webbutton(“html id:=signIn”).click
‘ ************************ This loop does not work **************************
Elseif Browser(“title:=Gmail: Email from Google”).Page(“title:=Gmail: Email from Google”).WebElement(“innertext:=The username or password you entered is incorrect. ?”).Exist then
msgbox (“Incorrect Login”)
.webedit(“html id:=Email”).set “qtptes@gmail.com”
.webedit(“html id:=Passwd”).setsecure crypt.encrypt(“dfsdfsdfdf”)
wait(10)
.webbutton(“html id:=signIn”).click

else
reporter.reportevent 0,”Verify Login “,” Test Pass”
End If
end with

Reply

60 Anshoo Arora January 12, 2012 at 11:27 am

Try this to identify the error:

If Browser("title:=Gmail.*").WebElement("class:=errormsg").Exist(5) Then
    Reporter.ReportEvent micWarning, "Error", Browser("title:=Gmail.*").WebElement("class:=errormsg").GetROProperty("innertext")
End If

61 krish December 30, 2011 at 6:49 am

Hi Anshoo,
I am krishna,I need u r help.I am trying to perform click operation on compose functionality in gmail, qtp identifying the compose functionality but not performing click operation so i tried to use senkeys method still no use could u plz have a look on my code below and plz give an idea to run my script successfully.

code for compose functionality in GMAIL..

datatable.Import(“C:\login.xls”)
Browser(“title:=Gmail”).Page(“micclass:=page”).webelement( “innertext:=COMPOSE”,”width:=115″).click
wait(6)
set WshShell = CreateObject(“WScript.Shell”)
wshshell.sendkeys “{ENTER}”

Browser(“title:=Gmail”).Page(“micclass:=page”).WebEdit(“name:=to”).Set datatable(“mail_id”,1)
Browser(“title:=Gmail”).Page(“micclass:=page”).WebEdit(“name:=Subject”).Set datatatable(subject,”1″)
Browser(“title:=Gmail”).Page(“micclass:=page”).WebElement(“htmltag:=BODY”).Set datatable(body,”1″)
Browser(“title:=Gmail”).Page(“micclass:=page”).WebElement(“innertext:=Send”).Click

Reply

62 Anonymous January 3, 2012 at 5:30 am

pls try this link.. it might work

Browser(“title:=Gmail – Inbox”).Page(“title:=Gmail – Inbox”).link(“text:=Compose Mail”,”html tag:=A”).Click

63 Anshoo Arora January 12, 2012 at 11:29 am

Krish,

Change the ReplayType and try to click:

Setting.WebPackage("ReplayType") = 2
'click
Setting.WebPackage("ReplayType") = 1

64 byzoor January 2, 2012 at 7:25 am

Signout Class name is Changed:
Browser(“title:=Gmail.*”).Page(“micclass:=Page”).Link(“innertext:=Sign Out”, “class:=gb4″).Click

Reply

65 byzoor January 2, 2012 at 7:50 am

With Browser(“title:=Gmail.*”).Page(“title:=Gmail.*”)
If .Link(“innertext:=Compose Mail”,”html tag:=A”).Exist(10) Then
.Link(“innertext:=Compose Mail”,”html tag:=A”).Click 1,1,micLeftBtn
If .WebEdit(“name:=to”).Exist(10) Then
.WebEdit(“name:=to”).Set “byzoor@gmail.com”
If .WebEdit(“name:=subject”).Exist(10) Then
.WebEdit(“name:=subject”).Set “Test Mail”
Setting.WebPackage(“ReplayType”) = 2
If .WebButton(“name:=Send”, “html tag:=INPUT”, “index:=0″).Exist(10) Then
.WebButton(“name:=Send”, “html tag:=INPUT”, “index:=0″).Click 1,1,micLeftBtn
.Sync
Else
MsgBox( “Send button Not found”)
End If
Setting.WebPackage(“ReplayType”) = 1
Else
MsgBox( “Subject text box Not found”)
End If
Else
MsgBox( “To text box not found”)
End if
Else
MsgBox( “Compose Mail link not found”)
End If
End With

Reply

66 krish January 5, 2012 at 3:34 pm

Hi Anshoo,
This is krish,could u plz help me how to write a script for deleting mails in gmail.Qtp identifying the checkbox as a webelement in this case so plz give me an idea.
Thank you,
Regards,
krish

Reply

67 Anshoo Arora January 12, 2012 at 11:50 am

Krish, you can use the following line of code to select an email in Gmail:

Browser("title:=Gmail.*").WebTable("class:=F cf zt").WebElement("class:=T-Jo-auh", "index:=0").Click
Browser("title:=Gmail.*").WebTable("class:=F cf zt").WebElement("class:=T-Jo-auh", "index:=1").Click

68 krish January 12, 2012 at 12:50 pm

thank you..i will try it then getback to u if i have any problem with code..

69 Narasimha January 9, 2012 at 4:27 pm

hi,
how to click the image older emails in standard view.i.e if i want to see 60th mail then i should click on “>” image from standard view, how we can achive this using qtp descriptive programming.

Reply

70 krish January 19, 2012 at 11:06 am

Hi anshoo,
The above code (reading email) is not working.Itied to execute in my machine.getting message like
“The statement contains one or more invalid function arguments.

Line (5): “.ChildItem(iRow, 3, “WebElement”, 0).Click”. ”
could u plz check out.
Thank you,
regards,
krish

Reply

71 naresh January 25, 2012 at 2:20 am

write test script in dp below scenario:
1.launch google site,
2.get all links in google site,
3.apply spell check on every link name,
4.close google site

Reply

72 Joseph January 30, 2012 at 7:44 am

Hi, Ashoo

I am trying to get number of total e-mails in Inbox (appeared as “1–8 of 8″ in top right corner of e-mail) and using this line as you suggested:

sText = Browser(“title:=Gmail.*”).Page(“title:=Gmail.*”).WebElement(“innertext:=\d+-\d+ of \d+”, “index:=0″).GetROProperty(“innertext”)

I am getting error: Can not recognize WebElement…

Could you please

Reply

73 Joseph February 3, 2012 at 9:44 am

Sorry, my previous post was not completed. So the question is : how to troubleshoot such error (when QTP can not read the text from web page) ? Thanks

74 San March 30, 2010 at 12:42 am

You are welcome, Anshoo
:)

Reply

75 Anu May 18, 2010 at 11:11 pm

Hi Anshoo,

My question is if i have many links on the web page such as 1,2,3,4…………. and so on then each time i have to manually click on these links. Suppose my QTP script is

Browser(“Browser”).Page(“page”).Link(“2″).Click

Browser(“Browser”).Page(“page”).Link(“3″).Click
….
.
.
.
.
.
And so on .

Instead of recoding these link each time i want to use regular expression in the Object repository on the of the links.

Hope this explain my question.

Thanks for response.

Regards,
Anu

Reply

76 Anshoo Arora May 26, 2010 at 8:42 am

How about this:

For ix = 1 to 10
    Browser(“Browser”).Page(“page”).Link(“″ & ix).Click
Next

Reply

77 Anonymous May 27, 2010 at 11:52 pm

Hi Anshoo,

It is working fine for first link but when it navigates to other link error massage display saying “Link object was not foumd in the object repository.”

Regards,
Anu

Reply

78 Anshoo Arora June 1, 2010 at 5:44 am

You will have to navigate back to the page where the link object exists..

Reply

79 kishore August 4, 2010 at 2:14 am

Hey anshoo,

It is not working. Please let me know the solution

Reply

80 Anshoo Arora August 5, 2010 at 2:03 pm

Kishore,

Instead of using the Regex in the inline description, you will have to use it directly in the OR instead. Also, you can move all objects under the Frame to under the Page object.

In other words, your hierarchy at the moment is:

Browser
– Page
– Frame
– Link (Sign Out)

When you move the object under page, the hierarchy becomes:

Browser
– Page
– Frame
– Link (Sign Out)

I would still suggest to use the ReGex for Frame directly in the OR.

Reply

81 kishore August 7, 2010 at 7:29 am

Hi Anshoo,
Thanks for you reply. It is working now. But if the another framename is starting with ‘c’, it will not work. I,e. The singout link is under a frame which starts witj ‘c’ and compose mail link is under a different frame which also starts with ‘c’. In this case the we get an error if we use the regular expression ‘c.*” for two objects.

Now my question, can we skip this frame object while click on a web link.

I have used the following, but did n’t work out.
1. Browser(“title:=Gmail.*).Page(“title:=Gamil.*).Link(“innertext:=Compose Mail”).Click -9999, -9999
2. Browser(“title:=Gmail.*).Page(“title:=Gamil.*).Link(“innertext:=Compose Mail”, “html id :=:rd).Click -9999, -9999
3. Browser(“title:=Gmail.*).Page(“title:=Gamil.*).Link(“innertext:=Compose Mail”, “x:=33″, “y:=109″).Click -9999, -9999

Note: I am using descriptive progamming and i didn’t store the objects in OR. However i spied these links but i didn’t get any ordinal poperties such as index.
So, can you guide me how to click on links in a page independent of Frames. if you give exact one liner scipts(Gmail signout, gmail compose mail code lines) it would be very helpful for me.
In case if frames needs to be used then how to deal with those when name starts with the same letter.

Thanks
kishore

Reply

82 Anshoo Arora August 8, 2010 at 7:49 pm

Now my question, can we skip this frame object while click on a web link.

Yes. You can also skip the Page object.

Browser(“title:=Gmail.*).Page(“title:=Gamil.*).Link(“innertext:=Compose Mail”).Click -9999, -9999

Notice the title description for your page object. It is Gamil, instead of GMail. Try this:

Browser("title:=Gmail.*").WebElement("html id:=:rd").Click

Reply

83 Wei Di August 9, 2010 at 3:17 am

open the object repository and use the “Navigate and Learn” Function, set the filter to select Frame and Link type of objects.4 Frames can be found and only one contains the “Sign out” link. Comparing all the properties of the frames, the html id is different.So, following is usable:
Browser(“title:=Gmail.*”).Page(“micclass:=Page”).Frame(“html id:=canvas_frame”).Link(“innertext:=Sign out”).Click

Reply

84 kishore August 9, 2010 at 8:08 am

I never thought I have to struggle 12 hrs to automate ‘compose mail’ functionality in gmail. But still I am unable to execute it successfully. I have been struggling to identify the objects of ‘compose mail link”, “To text box”, “subject text box”, “send button”. I can understand it is a simple issue but in real I am struggling,

The code i am using.
‘*****************************************************
If Browser(“title:=Gmail.*”).Page(“title:=Gmail.*”).WebElement(“innertext:=Compose Mail”, “html id:=:rd”, “html tag:=B”).Exist Then
Browser(“title:=Gmail.*”).Page(“title:=Gmail.*”).WebElement(“innertext:=Compose Mail”, “html id:=:rd”, “html tag:=B”).Click -9999, -9999
Browser(“title:=Gmail.*”).Page(“title:=Gmail.*”).Sync
If Browser(“title:=Gmail.*”).Page(“title:=Gmail.*”).WebEdit(“name:=to”, “class:=dK nr l1″, “rows:=2″).Exist Then
Browser(“title:=Gmail.*”).Page(“title:=Gmail.*”).WebEdit(“name:=to”, “class:=dK nr l1″, “rows:=2″).Set ” ”
If Browser(“title:=Gmail.*”).Page(“title:=Gmail.*”).WebEdit(“name:=subject”).Exist Then
Browser(“title:=Gmail.*”).Page(“title:=Gmail.*”).WebEdit(“name:=subject”).Set “hi”
If Browser(“title:=Gmail.*”).Page(“title:=Gmail.*”).WebButton(“name:=Send”).Exist Then
Browser(“title:=Gmail.*”).Page(“title:=Gmail.*”).WebButton(“name:=Send”).Click -9999, -9999
Browser(“title:=Gmail.*”).Page(“title:=Gmail.*”).Sync
Else
MsgBox( “Send button Not found”)

End If
Else
MsgBox( ” Subject text box Not found”)

End If
Else
MsgBox( “To text box not found”)
End if
Else
MsgBox( “Compose Mail link not found”)

End If

‘***************************************************
In some runs, some of the objects are being identified by QTP and in the next run same objects are not being identified.

I thought i would use Object repositary to store the objects and get them identified. But the above mentioned objects are lying under frames whose name starts with ‘c’. So i cant use c.* for all the frames.

Note: Before you suggest any code, please run it once on gmail and if it is passing then only put down here. Otherwise i end up loosing more time in implementing your code.

In some posts i read use the below to click on compose mail

Browser(“title:=Gmail.*”).WebElement(“html id:=:rd”).Click

but i didn’t work

Thanks,
kishore

Reply

85 Anshoo Arora August 9, 2010 at 8:33 am

PS. I just tried the following code and it works:

Browser("title:=Gmail.*").WebElement("html id:=:rd").Click

and this works for ‘to’ and ‘subject’ fields for me:

With Browser("title:=Gmail.*")
	.WebEdit("html id:=:14d").Set "to"
	.WebEdit("html id:=:14a").Set "subject"
End With

Note: Not all of us have the bandwidth to execute every bit of code before suggesting something. Not all solutions offered here are 100% proof, but 100% free. Sometimes, a solution works in one case, but fails in another. Moreover, regardless of how busy everyone is, they are still trying to put an effort to help each other here. If you feel considering a solution will waste your time, please don’t consider it. We just want to help you Kishore, not waste your time.

Reply

86 Anonymous August 9, 2010 at 9:13 am

Hi Anshoo,
Thanks for your reply. For some reason, the code you suggested is not working. It is failing to identify the compose mail link(What a bad day at work).
<>, i accept that, but my comments came from the frustration. I tryly appreciate the ppl who tries to help others.

Thanks
kishore

Reply

87 Anshoo Arora August 9, 2010 at 6:25 pm

No worries :)

Btw, the code that I gave you, I tested before posting here. It certainly works for me and looking at the HTML structure, the Compose Mail link has an HTML ID associated with it, which is generally a unique value. Therefore, we do not need any other identification properties if we have the ID of the object. I saw your code, there are a few changed I have made to it:

With Browser("title:=Gmail.*").Page("title:=Gmail.*")
	If .WebElement("innertext:=Compose Mail", "html tag:=SPAN").Exist(10) Then
		.WebElement("innertext:=Compose Mail", "html tag:=SPAN").Click
		If .WebEdit("name:=to").Exist(10) Then
			.WebEdit("name:=to").Set ""
			If .WebEdit("name:=subject").Exist(10) Then
				.WebEdit("name:=subject").Set "hi"
				Setting.WebPackage("ReplayType") = 2
				If .WebElement("innertext:=Send", "html tag:=B", "index:=0").Exist(10) Then
					.WebElement("innertext:=Send", "html tag:=B", "index:=0").Click
					.Sync
				Else
					MsgBox( "Send button Not found")
				End If
				Setting.WebPackage("ReplayType") = 1
			Else
				MsgBox( "Subject text box Not found")
			End If
		Else
			MsgBox( "To text box not found")
		End if
	Else
		MsgBox( "Compose Mail link not found")
	End If
End With

Reply

88 kishore August 10, 2010 at 12:54 am

Hi Anshoo,
Thank you very much for the help. It is working now(atlast). Yesterday i tried with different properties(for all the objects),
but it didn’t work. Is there any standard procedure to find certian objects with certain properties? I mean,
if need to find a link is there any standard properties using which it will be identified?
Why my code didn’t work eventhough i’ve provided losts of properties for each object.
I think everytime i am using browser(“”).Page(“”) code. Will it make any difference as you
used simple WITH statement.

Once i again thank you very much for your help.

Thanks
kishore

Reply

89 Anshoo Arora August 11, 2010 at 3:09 pm

The With statement only helps compartmentalize your code. There is no other use besides that. Instead of writing this:

Browser("Google").Page("Google").WebEdit("q").Highlight
Browser("Google").Page("Google").Link("Images").Highlight
Browser("Google").Page("Google").Link("Videos").Highlight
Browser("Google").Page("Google").Link("Maps").Highlight

You can simply write:

With Browser("Google").Page("Google")
	.WebEdit("q").Highlight
	.Link("Images").Highlight
	.Link("Videos").Highlight
	.Link("Maps").Highlight
End With

This makes it easier to follow the code. Also, when changing it, you only have to change it once for all related objects.

Reply

90 markQA February 20, 2011 at 1:14 am

Thanks Anshoo again. After some minor modifications of your suggested script, I came up with the following script…and its works like a charm. I am giving the full script, as I think for many new comer in QTP, this is a big challenge.

SystemUtil.Run"iexplore.exe","gmail.com"
'Sign in
Browser("title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=Email").Set "xyz"
Browser("title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=Passwd").Set "abc"
Browser("title:=Gmail.*").Page("title:=Gmail.*").WebButton("name:=Sign in").click
'Mouse click on compose button
Setting.WebPackage("ReplayType") = 2
Browser("title:=Gmail.*").WebElement("innertext:=Compose Mail", "class:=J-K-I-Jz").Click
Setting.WebPackage("ReplayType") = 1
Browser("title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=to").Set "xyz@gmail.com"
Browser("title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=subject").Set "Gmail Automation"
'Inserting text on body frame object
Set objEdit= Browser("title:=Gmail.*").Page("title:=Gmail.*").WebElement("html tag:=BODY", "html id:=:.*")
objEdit.Object.innertext="Testing gmail login, compose, file attach, send and sign out by using QTP-DP"

'Mouse click on Attach a file
Setting.WebPackage("ReplayType") = 2
Browser("title:=Gmail.*").Page("title:=Gmail.*").WebElement("html id:=FLASH_UPLOADER_1").Click
Setting.WebPackage("ReplayType") = 1
Wait(2)
'File attach
Dialog("nativeclass:=#32770").WinEdit("attached text:=File &name:", "index:=0").Type "c:\123.txt"
Dialog("nativeclass:=#32770").WinButton("text:=&Open").Click
Wait(10)
'Send Mail
Setting.WebPackage("ReplayType") = 2
Browser("title:=Gmail.*").Page("title:=Gmail.*").WebElement("innertext:=Send", "index:=0").Click
Setting.WebPackage("ReplayType") = 1
'Sign Out from Gmail
Browser("title:=Gmail.*").Page("title:=Gmail.*").Link("innertext:=Sign out", "html id:=:.*").Click
Browser("title:=Gmail.*").CloseAllTabs

One more question for you, after file attachment, before clicking on Send, we have to give time to upload, and if we don’t know the file size, its an uncertain factor. Any suggestion how to deal this issue generally?

Thanks for all your time my friend.

Reply

91 Anshoo Arora February 20, 2011 at 6:55 am

Mark, you can use the following code to loop until the file uploads:

While Browser("title:=Gmail.*").WebElement("class:=dQ").Exist(0)
	Wait(1)
Wend

Reply

Leave a Comment

{ 1 trackback }

Previous post:

Next post: