0

I have a requirement to automate the Gmail.Here i need to get the unread mail count of Lables like Inbox,spam,bulk etc.How can i get the count of unread mails using selenium RC. suppose the Lables as Inbox(5),Spam(10),Bulk(34). it mean that Inbox contains 5 unread mails, Spam contains 10 unread mails. So For this kind of requirement how can i achieve using Selenium RC?

Thanks & Regards, Shiva.enter image description here

shiva oleti
  • 775
  • 3
  • 16
  • 23

4 Answers4

2

I think that using standard IMAP client interface you will be able to get your task done much faster.

See working example in Perl and more official documentation on Mail::ImapClient

mvp
  • 111,019
  • 13
  • 122
  • 148
1
String inbox=selenium.getText("//a[contains(@title,'Inbox')]");

Now inbox String variable contains Inbox (1)

String unreadInboxMails=inbox.substring(inbox.indexOf("(")+1,inbox.indexOf(")"));

In this way you can get for all Labels like Spam, bulk etc. only thing you need to change is Label locator .

I hope this will solve your problem.

Santoshsarma
  • 5,627
  • 1
  • 24
  • 39
0

This is the exact selenese (Selenium IDE) code that gets the unread count of all folders and shows in an alert.

You can use it with Selenium RC by tweaking few commands.

store | //div[@class='LrBjie']/div/div[ | target1
store | ]/div/div/div/span/a | target2
store | 1 | i
store | true | present
store |  | countsAll
while | ${present}==true | 
storeEval | storedVars['target1']+storedVars['i']+storedVars['target2'] | target
echo | ${target} | 
storeText | javascript{storedVars['target']} | counts
storeEval | storedVars['countsAll']+'  $  '+storedVars['counts']   |   countsAll
echo | ${countsAll} | 
storeEval | parseInt(storedVars['i'])+1 | i
storeEval | storedVars['target1']+storedVars['i']+storedVars['target2'] | target
storeElementPresent | javascript{storedVars['target']} | present
echo | ${present} | 
endWhile |  | 
storeEval | javascript{alert(storedVars['countsAll'])} | countsAll
josliber
  • 43,891
  • 12
  • 98
  • 133
MCKiran
  • 57
  • 3
  • 9
-1
WebDriver gmail = new ChromeDriver();
//Inbox count using xpath. From this output you can separate count from the string 'Inbox(20)'
WebElement inbox = gmail.findElement(By.xpath("//*[@id=':bb']/div/div[1]"));
System.out.println(inbox.getText());
Termininja
  • 6,620
  • 12
  • 48
  • 49