I've written a few tests using Selenium WebDriver for an internal application that uses Google Cloud Platform's IAP solution for authentication. The Google login flow works absolutely well when the tests are targeted to my local Chrome browser or even to the Selenium Chrome standalone Docker image container running locally. However, whenever I run the tests on a CI agent, it gets a CAPTCHA as seen in the screenshot below.
The tests run in a GitLab CI runner with below config.
services:
- selenium/standalone-chrome-debug:latest
As per the points mentioned in this answer, I tried setting the viewport size to 1920x934 (which is the viewport size from my local setup) and slow down email entry by introducing a 500ms delay between each email address character. But that does not help. Below is the code for viewport setup.
int width = 1920;
int height = 934;
JavascriptExecutor js = (JavascriptExecutor) this.driver;
String windowSize = js.executeScript("return (window.outerWidth - window.innerWidth + " + width + ") + ',' + (window.outerHeight - window.innerHeight + " + height + "); ").toString();
//Get the values
width = Integer.parseInt(windowSize.split(",")[0]);
height = Integer.parseInt(windowSize.split(",")[1]);
//Set the window
this.driver.manage().window().setSize(new Dimension(width, height));
LOG.info("New dimensions: " + this.driver.manage().window().getSize().getWidth() + " x " + this.driver.manage().window().getSize().getHeight());
Now since CAPTCHA is not observed locally, I'm sure there has to be something specific to the CI setup that's causing CAPTCHA to come up, but not sure what exactly could be the cause. I even tried setting my local machine's time to UTC (this is the timezone of the CI agent), but the CAPTCHA isn't seen with this.
