ruby - 如何修复 Linux 中的 "usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed"错误?

标签 ruby linux selenium-webdriver amazon-linux

我正在尝试设置一个 jenkins 服务器以在 Amazon Linux 上使用 Selenium-webdriver(3.142.0) 和 ruby​​(2.3.7) 托管我的自动化框架。如果我尝试使用我的脚本调用 chromedriver,它会说,

"Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: exited abnormally (unknown error: 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.) (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Linux 4.14.104-95.84.amzn2.x86_64 x86_64)".

我已将我的 chromedriver 放在 '/var/lib/jenkins/driver/chromedriver' 下,并在 .bashrc 中设置相同的 PATH,还为它创建了一个指向 '/usr/bin/google-chrome 的符号链接(symbolic link)'.以下是我正在使用的机器的详细信息:

    NAME="Amazon Linux"
    VERSION="2"
    ID="amzn"
    ID_LIKE="centos rhel fedora"
    VERSION_ID="2"
    PRETTY_NAME="Amazon Linux 2"
    ANSI_COLOR="0;33"
    CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
    HOME_URL="https://amazonlinux.com/"```

require 'selenium-webdriver'
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument("--disable-dev-shm-usage");
options.add_argument('--no-sandbox')
driver = Selenium::WebDriver.for :chrome, options: options



>Expected result: Browser should be invoked.
>Actual result: 
Exits with the error "The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed."

最佳答案

Chrome 未安装在默认位置。 chromedriver check for chrome安装在linux系统默认位置/usr/bin/google-chrome。如果您在非标准位置使用 Chrome,则需要覆盖 Chrome 二进制位置。

caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"binary" => "Actual Path"})

关于ruby - 如何修复 Linux 中的 "usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55862006/

相关文章:

ruby - 如何从 DateTime 值中删除区域?

Firefox 37 和 Selenium Webdriver 2.45

java - 无法使用 chrome 和 gecko 驱动程序执行 selenium java 程序

ruby - Jekyll 在 frontmatter 中错误的日期识别

ruby - 是否可以使 PhantomJS 在 Watir-WebDriver 中可见?

Linux:用 10^10 条记录对 500GB 的文本文件进行排序

php - 为时区编辑 php ini

java - 如何使用 Undertow 启用跨域源

python - 无法使用 send_keys 或 requests 上传 pdf 文件

ruby - 自定义 attr_reader 以进行属性的惰性实例化