Chrome 驱动程序版本 92 未 运行 测试

Chrome driver version 92 not running tests

我在 运行 92 版浏览器打开时遇到问题,在无头模式下工作正常。

我目前正在 运行 对 docker 容器进行测试。 chrome-驱动程序的安装如下:

RUN curl -s https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && \
    apt-get update && \
    apt-get install -y \
    xvfb \
    google-chrome-stable=92.\* \
    unzip

RUN curl -s -o /tmp/chromedriver.zip "https://chromedriver.storage.googleapis.com/$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE_92)/chromedriver_linux64.zip" && \
    unzip /tmp/chromedriver.zip chromedriver -d /usr/bin/ && \
    chmod +x /usr/bin/chromedriver

执行我的命令 运行 测试后,浏览器打开但没有任何反应。 我被数据困住了;在地址栏上,页面会一直加载。

我目前正在使用 chrome 选项:

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--incognito")
chrome_options.add_argument("--disable-dev-shm-usage")

看起来它与 Linux 上的旧 Nvidia 驱动程序 运行 有关:

You may need to run with --disable-gpu on Linux with NVIDIA driver older than 295.20

来源:chromium documentation

所以,添加 chrome_options.add_argument("--disable-gpu") 解决了我的问题。