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());