0

public class AutoEmail { public static void main(String[] args) throws InterruptedException, FileNotFoundException, IOException, ParseException {enter image description here

    System.setProperty("webdriver.chrome.driver", "C:\\Users\\try\\Documents\\NetBeansProjects\\AutoEmail\\chromedriver.exe");

    ChromeOptions options = new ChromeOptions();
    options.addArguments("start-maximized");
    options.setExperimentalOption("useAutomationExtension", false);
    options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
    WebDriver driver =  new ChromeDriver(options); 

    driver.get("https://accounts.google.com/ServiceLogin?");

    new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='identifierId']"))).sendKeys("email@gmail.com");
    driver.findElement(By.id("identifierNext")).click();

    new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@name='password']"))).sendKeys("password");
    driver.findElement(By.id("passwordNext")).click();
}

}

Ace
  • 27
  • 7
  • If you gonna often run the script, google might stop sign in due to security concern. Have you successfully run your code once as i can not see any mistakes in code ? @Ace. – Techie Jan 29 '20 at 06:19

1 Answers1

3

A quote from support.google.com:

To help protect your account, Google doesn’t let you sign in from some browsers. Google might stop sign-ins from browsers that:

  1. Don’t support JavaScript or have Javascript turned off.
  2. Have unsecure or unsupported extensions added.
  3. Use automation testing frameworks.
  4. Are embedded in a different application.
Mikhail
  • 211
  • 1
  • 7