Open Gmail inbox and get the unread mails count using Selenium Webdriver

0 votes
Anyone please suggest how to automate opening gmail inbox and getting a count of unread mails using Selenium Webdriver?
May 20 in Selenium by Naitik
350 views

1 answer to this question.

0 votes

Hi Naitik, you can follow this piece of code to achieve this type of automation using Selenium Webdriver:

System.setProperty("webdriver.chrome.driver", C:\\Users\\Abha_Rathour\\Downloads\\ExtractedFiles\\chromedriver_win32\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

driver.manage().window().maximize();

driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

driver.get("https://gmail.com/");

driver.findElement(By.id("identifierId")).sendKeys("email_id");

driver.findElement(By.className("CwaK9")).click();   // Identifier for Next button

driver.findElement(By.xpath("//*[@id=\"password\"]/div[1]/div/div[1]/input")).sendKeys("password");

driver.findElement(By.className("CwaK9")).click();   // Identifier for Next button

// Get title of the current page
System.out.println("Title of Page: " + driver.getTitle());
// List of all Unread Emails
List<WebElement> unreademail = driver.findElements(By.className("zE"));
// Display count of unread emails
System.out.println("Total No. of Unread Mails: " + unreademail.size());
answered May 21 by Abha
• 19,130 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How to get the select options using Selenium WebDriver in Java

Hey there! You should be able to get ...READ MORE

answered Jun 13 in Selenium by Surya
• 990 points
75 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
403 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
760 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
400 views
0 votes
1 answer