我的问题是如何在docker容器中运行google chrome进行e2e测试.我创建了一个Dockerfile官方Jenkins图像,但是当尝试运行谷歌浏览器时,它会崩溃并显示错误:
Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
Trace/breakpoint trap (core dumped)
Run Code Online (Sandbox Code Playgroud)
Jenkins docker镜像使用Debian jessie.
我可以用--headless旗帜运行谷歌浏览器,不需要X服务器.
这是我的docker文件:
詹金斯官方形象:
一个人使用来自docker的GUI运行google chrome:
我的第一种方法是使用xvbf,但使用--headlessflag 时过程更简单.
我可以使用相同的安装命令在Ubuntu服务器上运行chrome,但是在docker中它会失败.
在其他意图之后,我使用了--no-sandboxflag,但是docker图像显示了下一个错误.
[0427/180929.595479:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected
[0427/180929.595537:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected
libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Operation not permitted
Run Code Online (Sandbox Code Playgroud)
其实我运行了这个命令:
google-chrome-stable --headless --disable-gpu --no-sandbox http://www.google.com
我是Selenium的新人,我现在可以用selenium和Chromedriver做基本的自动测试,代码运行正常,但问题是Chrome浏览器总是在后端自动更新,Chrome更新后代码总是无法运行. 我知道我需要下载新的 chromedriver 来解决这个问题,但我想知道是否有任何方法可以在不禁用 chromebrowser 更新的情况下解决这个问题?tks。
我使用的是 Windows 10 / Chrome 版本 67 / Python 3.6.4 / Selenium 3.12.0
python selenium google-chrome selenium-chromedriver selenium-webdriver