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



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

"Selenium::WebDriver::Error::UnknownError: 未知错误: Chrome 无法启动: 异常退出 (未知错误:DevToolsActivePort 文件不存在( (从chrome位置/usr/bin/google-chrome开始的进程不再运行,因此ChromeDriver假设Chrome已经崩溃。 (驱动程序信息: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中设置了相同的路径,并为它创建了一个符号链接到'/usr/bin/google-chrome'。以下是我正在使用的机器的详细信息:

    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 未安装在默认位置。Chrome 的 Chrome 驱动程序检查安装在 Linux 系统的默认位置/usr/bin/google-chrome。如果您在非标准位置使用 Chrome,则需要覆盖 Chrome 二进制位置。

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

相关内容

最新更新