Google 登录验证码仅出现在 CI 中

问题描述 投票:0回答:1

我使用 Selenium WebDriver 为内部应用程序编写了一些测试,该内部应用程序使用 Google Cloud Platform 的 IAP 解决方案进行身份验证。当测试针对我的本地 Chrome 浏览器,甚至是本地运行的 Selenium Chrome 独立版 Docker 镜像容器时,Google 登录流程工作得非常好。但是,每当我在 CI 代理上运行测试时,它都会获得验证码,如下面的屏幕截图所示。

测试在具有以下配置的 GitLab CI 运行器中运行。

services:
- selenium/standalone-chrome-debug:latest

根据此答案中提到的要点,我尝试将视口大小设置为 1920x934(这是我本地设置的视口大小),并通过在每个电子邮件地址字符之间引入 500 毫秒的延迟来减慢电子邮件输入速度。但这没有帮助。下面是视口设置的代码。

    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());

现在由于在本地未观察到 CAPTCHA,我确信 CI 设置中一定有某些特定内容导致出现 CAPTCHA,但不确定到底是什么原因。我什至尝试将本地计算机的时间设置为 UTC(这是 CI 代理的时区),但没有看到验证码。

java selenium selenium-webdriver webdriver
1个回答
-1
投票

你找到解决办法了吗?我有类似的问题,验证码仅显示在 Docker 中。

© www.soinside.com 2019 - 2024. All rights reserved.