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

selenium

 

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.support.ui.ExpectedConditions;

import org.openqa.selenium.support.ui.WebDriverWait;


public class GmailDemo {

public static void main(String[] args) {

WebDriver driver = new FirefoxDriver();

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

String url = "https://accounts.google.com/signin";

driver.get(url);

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

//driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

WebDriverWait wait=new WebDriverWait(driver, 20);

driver.findElement(By.xpath("//span[@class='RveJvd snByac']")).click();

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

driver.findElement(By.xpath("//input[@class='whsOnd zHQkBf']")).sendKeys("asassassa");

driver.findElement(By.xpath("//span[@class='RveJvd snByac']")).click();

}

}

 

The problem is that, after mail id page, my password is getting written in the id box option & the server redirects to next password page. I want to ask, what should I do so that my password would be entered only in password page?
 

1
Answers

Replies

System.setProperty("webdriver.gecko.driver","C:\\your_directory\\geckodriver.exe");



    WebDriver driver = new FirefoxDriver();



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



    String url = "https://accounts.google.com/signin";



    driver.get(url);



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



    WebElement email_phone = driver.findElement(By.xpath("//input[@id='identifierId']"));



    email_phone.sendKeys("your_email_phone");



    driver.findElement(By.id("identifierNext")).click();



    WebElement password = driver.findElement(By.xpath("//input[@name='password']"));



    WebDriverWait wait = new WebDriverWait(driver, 20);



    wait.until(ExpectedConditions.elementToBeClickable(password));



    password.sendKeys("your_password");



    driver.findElement(By.id("passwordNext")).click();

 
 

If you want to unleash your potential in this competitive field, please visit the selenium course page for more information, where you can find the selenium tutorials and selenium frequently asked interview questions and answers as well.

 

This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.