How to automate gmail login process using selenium webdriver in java?

We can automate the Gmail login process using Selenium webdriver in Java. To perform this task, first we have to launch the Gmail login page and locate the email, password and other elements with the findElement method and then perform actions on them.

Let us have the look at the Gmail login page −

Code Implementation

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
public class GmailLogin{
   public static void main(String[] args) {
      WebDriver driver = new FirefoxDriver();
      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      //URL launch
      //identify email
      WebElement l = driver
      WebElement b = driver
      //identify password
      WebElement p = driver
      //close browser

Updated on: 25-Jun-2021

11K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started