如何修复“ usr / bin / google-chrome不再运行,因此ChromeDriver假定Chrome已经崩溃”。 Linux中的错误? [英] How to fix "usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed" error in Linux?
问题描述
我正在尝试设置一个jenkins服务器,以在Amazon Linux上使用Selenium-webdriver(3.142.0)和ruby(2.3.7)托管我的自动化框架。如果我尝试使用脚本调用chromedriver,它会显示
I'm trying to setup a jenkins server to host my automation framework with Selenium-webdriver(3.142.0) and ruby(2.3.7) on Amazon Linux. If I try to invoke a chromedriver using my script, it says,
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 )。
"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'下,并设置了PATH在.bashrc中也是如此,并且还为 / usr / bin / google-chrome创建了相同的符号链接。以下是我使用的计算机的详细信息:
I've placed my chromedriver under '/var/lib/jenkins/driver/chromedriver' and set the PATH for the same in .bashrc and also created a symlink for the same to '/usr/bin/google-chrome'. Below are the details of the machine that I'm using:
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未安装在默认位置。对于Linux系统,ChromeDriver check for Chrome安装在默认位置 / usr / bin / google-chrome
中。如果您在非标准位置使用Chrome,则需要覆盖Chrome二进制位置。
Chrome is not installed on default location. ChromeDriver check for Chrome is installed in the default location /usr/bin/google-chrome
for linux system. If you are using a Chrome in a non-standard location then you need to override Chrome binary location.
caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"binary" => "Actual Path"})
这篇关于如何修复“ usr / bin / google-chrome不再运行,因此ChromeDriver假定Chrome已经崩溃”。 Linux中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!