This code works to login to gmail
public void login(User user) {
WebDriverWait wait = new WebDriverWait(driver, 60);
WebElement emailTextBox = wait.until(
ExpectedConditions.visibilityOfElementLocated(By.id("identifierId")));
emailTextBox.sendKeys(user.email);
WebElement nextButton = wait.until(
ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[contains(text(), 'Next')]")));
nextButton.click();
WebElement passwordTextBox = wait.until(
ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@type='password']")));
passwordTextBox.sendKeys(user.password);
nextButton = wait.until(
ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[contains(text(), 'Next')]")));
nextButton.click();
}
Problem
We have a web application under test where users can login with google (oAuth2), however gmail traps automation script with a user verification (reset password or captcha or phone number).
Q:
Is there any way to avoid gmail user verification ?
(I am not asking to solve google verification challenge, in normal browser run by user manually this verification challenge doesn't get triggered (most of times), but with selenium it sometimes happens and fails my tests.)
Update 19.08.2018
This is a dead end, bypassing google verification is not trivial, upon searching more I found that service virtualization is the correct way to solve this issue, possibly Hoverfly.