Google login is not working in headless chrome selenium in Jenkins job Google login is not working in headless chrome selenium in Jenkins job jenkins jenkins

Google login is not working in headless chrome selenium in Jenkins job


Solved google login issue by adding --user-agent flag with headless chrome.

--user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36"

Ref: Headless Chrome displays old Google sign-in when signing in with OpenID/OAuth


Chrome headless browser won't necessarily have the same screen size set as the normal Chrome (I think it is 800 x 600, but I'm not sure).

Try adding the following options:

chromeOptions.addArguments("--start-maximized");chromeOptions.addArguments("--window-size=1200,800");

Obviously, set the screen size you want in the place of 1200x800.


I used to have the same problem, in headless used other google login page. I resolved it this way:

driver.get("https://accounts.google.com/signin/v2/identifier");    WebElement emailField = driver.findElement(By.id("Email"));    emailField.sendKeys(login);    WebElement loginNext = driver.findElement(By.id("next"));    loginNext.click();    logger.info("Enter password");    WebElement passwordField = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("Passwd")));    passwordField.sendKeys(password);    WebElement passwordNext = driver.findElement(By.id("signIn"));    passwordNext.click();