Linux环境Codeception测试遇ChromeDriver DevToolsActivePort不存在错误
问题背景与现象
我在Linux流水线中使用Google Chrome和ChromeDriver运行Codeception测试。此前通过.deb包安装的Chrome版本可正常运行,但因Chrome与ChromeDriver版本不兼容,切换为Chrome for Testing后测试无法启动。
我将Chrome for Testing的文件解压到/tmp/chrome/chrome-linux64/后移至/opt/google/chrome/,并创建软链接到/usr/bin/google-chrome(基于自定义Docker镜像):
ln -s /opt/google/chrome/chrome /usr/bin/google-chrome
尝试多种解决方案后,所有Codeception测试仍报以下错误:
[Facebook\WebDriver\Exception\SessionNotCreatedException] session not created: Chrome failed to start: exited normally. (session not created: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
我已修改Chrome选项修复了之前的所有dbus错误,且在Codeception实例外单独运行Chrome可正常工作。当前测试套件配置如下:
[...] modules: enabled: - WebDriver: url: http://127.0.0.1/index.php port: 9515 os: linux browser: chrome capabilities: acceptInsecureCerts: true platformName: "linux" chromeOptions: args: ["--no-sandbox", "--headless=new", "--disable-gpu", "--window-size=1920,1080", "--start-maximized", "--disable-extensions", "--proxy-server='direct://'", "--proxy-bypass-list=*", "--disable-dev-shm-usage", "--ignore-certificate-errors", "--remote-allow-origins=*"] binary: "/usr/bin/google-chrome" [...]
我通过以下命令在后台启动ChromeDriver(命令未变更且可正常运行):
nohup /usr/bin/chromedriver --url-base=wd/hub &
测试失败后执行ps aux命令,发现Chrome残留大量CrashPad僵尸进程:
root 1167 0.0 0.0 0 0 ? Z 13:17 0:00 [chrome_crashpad] <defunct> root 1173 0.0 0.0 0 0 ? Z 13:17 0:00 [chrome_crashpad] <defunct> root 1175 0.0 0.0 0 0 ? Z 13:17 0:00 [chrome_crashpad] <defunct> root 1181 0.0 0.0 0 0 ? Z 13:17 0:00 [chrome_crashpad] <defunct> root 1183 0.0 0.0 0 0 ? Z 13:17 0:00 [chrome_crashpad] <defunct> root 1189 0.0 0.0 0 0 ? Z 13:17 0:00 [chrome_crashpad] <defunct> root 1191 0.0 0.0 0 0 ? Z 13:17 0:00 [chrome_crashpad] <defunct> root 1197 0.0 0.0 0 0 ? Z 13:17 0:00 [chrome_crashpad] <defunct> root 1199 0.0 0.0 0 0 ? Z 13:17 0:00 [chrome_crashpad] <defunct> root 1205 0.0 0.0 0 0 ? Z 13:17 0:00 [chrome_crashpad] <defunct> root 1207 0.0 0.0 0 0 ? Z 13:17 0:00 [chrome_crashpad] <defunct>
内容的提问来源于stack exchange,提问作者mk55k
相关产品推荐
相关产品推荐

