Can you count the number of emails in Gmail’s standard view?

Seeing similar queries often in my mail box these days, so I decided to record a couple of videos.

In case, If you haven’t counted emails in standard view (of Gmail) using QTP earlier, I would suggest you to attempt it now.  It becomes a bit interesting especially if you have never worked on frames before. Also watch the videos below it has a couple of methods to deal with dynamic objects and frame objects.

Counting number of emails in basic HTML view…

Counting number of emails in standard view…

This is the function in the videos above to extract the number from Inbox string -

msgbox mid(strText, instr(1,strText,"(") + 1, (instr(1,strText,")") - instr(1,strText,"(") - 1))

19 comments ↓

#1 Sunny on 07.23.10 at 02:03

Very useful and interesting tips and pieces of code. Thaks a lot for all these points to learn and explore more on tool.

#2 Rashmikant Parmar on 07.24.10 at 00:22

Thanks you Ankur. Nice piece of work. But the only problem with this code displayed in video to capture the no of emails is, it will fail if there is no emails. Following code will work for both the situation.
This is for HTML view.

vMails = Browser(“Gmail – Inbox”).Page(“Gmail – Inbox”).Link(“Inbox (15)”).GetROProperty(“text”)

vP1 = Instr(1, vMails, “(“,1)
vP2 = Instr(1, vMails, “)”,1)
If vP1 0 AND vP2 0 Then
vMails = Mid(vMails, vP1 + 1, vP2 – vP1 -1 )
Else
vMails = 0
End If
Msgbox “You have “&vMails&” New Emails”

#3 Ankur on 07.24.10 at 20:02

@Rashmikant: Correct. The idea was to show the approach. It can be customized depending upon the requirement.

#4 vijay on 07.24.10 at 21:29

hi it very excelent

#5 Rashmikant Parmar on 07.24.10 at 23:19

It is an excellent Idea. you are correct we can customize according to the requirement. I just want to share the point of customization that we can do with this beautiful idea. I greatly appreciate your inputs in the field of Test Automation. I love this website and learned a lot when I was preparing for QTP certification which I cleared last month with the great help of this website.

#6 srinivasulu.t on 08.19.10 at 17:20

It is very help to me that code, i am saying really thanks to Ankur, But Ankut i want some clarrification that is :- How Count the number of mails in gmail in standard view (u r saying that is only unread mails. But i want total number of mails in gmail

#7 Srinivas Rao on 08.27.10 at 00:35

Hi Friends,
I want to learn qtp from realtime guys in hyderabad ,if interested mail me srinivas.mamidla@gmail.com,

thanks in advance

#8 Jayachandra Reddy on 09.19.10 at 11:15

Hi Ankur,

Really Gr8 and Nice Articles you posted really helps to freshers to experienced person in field of automation.. Really Nice Work .. I learned alot with ur blogs.. Thanks alot…

#9 Bommy on 09.21.10 at 16:27

Hey Ankur, U r giving wonderfull KT to QTP learners, gr8 job guy,thanks.

#10 Sesha reddy on 09.26.10 at 15:19

Good

#11 sibina on 09.28.10 at 14:39

Ankur,

Can you please explain how to check whether the last page is displayed or not when we click on “Last button” from the pagination bar.

Sibina

#12 Pratap H S on 10.20.10 at 10:44

sibina , capture the last page object and check with .Exists or u can take the last page unique property and check weather its returning TRUE or FALSE .

Regards
Pratap H S
prataphs@gmail.com

#13 Muruganandhan on 10.30.10 at 21:21

Hi…I am ok with your code, why this logice to be used…
Simple like Msgbox Replace(strText,”Inbox “,”")

#14 JOhn on 11.04.10 at 18:47

i am interested to record and run following thing using QTP and fill all values in DataTable

i will explain it by example

1. Open Url http://www.codeproject.com/KB/aspnet/

2. You will get articles on following topic
* ASP.NET – Cookies
* ASP.NET – Data
* ASP .NET – General
* ASP.NET – Howto
* ASP.NET – Printing
* ASP.NET – Reporting
* ASP.NET – Samples
* ASP.NET – Utilities
* ASP.NET – Web Parts

3. I think this is WebControl ListView

4. i would like to get all tiles according to Asp.Net Categories as following in dataTable of Qtp of Each webPage by click automatically

ASP.NET – Cookies

ASP.NET – Data

ASP .NET – General

ASP.NET – Howto

ASP.NET – Printing

Beginner’s Guide To ASP.NET Cookies

Pivoting DataTable Simplified

SDLC Checklist for Globalized ASP.Net Web Applications.

Providing Web Applications with Context Sensitive Help Using RoboHelp WebHelp

Merge Landscape and Portrait PDFs using ASP.NET

#15 Azad on 12.12.10 at 11:40

Thanks Ankur for nice posting. Kindly keem on posting such article it really helps learner a lot and i have been definately benifciated a lot. Thanks

#16 prakash on 12.24.10 at 15:36

Thanks Ankur for nice posting

#17 Viplav on 01.21.11 at 10:32

@Rashmikant Parmar IN your code above
I was trying to figure out if the below code is correct ?
If vP1 0 AND vP2 0 Then
vMails = Mid(vMails, vP1 + 1, vP2 – vP1 -1 )
Else
vMails = 0
End If

#18 rashmikant parmar on 01.22.11 at 05:58

@ Viplav
Mails = Browser(“Gmail – Inbox”).Page(“Gmail – Inbox”).Link(“Inbox (15)”).GetROProperty(“text”)

vP1 = Instr(1, vMails, “(“,1)
vP2 = Instr(1, vMails, “)”,1)
If vP10 AND vP20 Then
vMails = Mid(vMails, vP1 + 1, vP2 – vP1 -1 )
Else
vMails = 0
End If
Msgbox “You have “&vMails&” New Emails”

#19 Viplav on 01.25.11 at 23:03

Oh..

Perhaps i saw a bit in hurry that day..
thanks for your patience to replicate the code.. :)

Leave a Comment