我正在尝试设置一个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中为其设置了PATH,还为它创建了一个符号链接到'/ usr / bin / google-chrome '。以下是我正在使用的计算机的详细信息:
import plotly.graph_objs as go
from plotly.offline import plot
value = [3,5,2,4,6]
source = [0,0,1,0,3]
target = [1,4,2,3,4]
color = ["blue","yellow","orange","orange","purple"]
label = ["A","B","C1","C2","D"]
data = dict(
type='sankey',
arrangement = 'freeform',
node = dict(
pad = 15,
thickness = 20,
line = dict(
color = "black",
width = 0.1
),
groups = [[2,3]],
label = label,
color = color,
),
link = dict(
source = source,
target = target,
value = value,
)
)
layout = dict(
title = "Sankey test",
font = dict(
size = 10
)
)
f = go.FigureWidget(data=[data], layout=layout)
plot(f)
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
答案 0 :(得分:0)
Chrome未安装在默认位置。对于Linux系统,ChromeDriver检查Chrome是否安装在默认位置/usr/bin/google-chrome
中。如果您在非标准位置使用Chrome,则需要覆盖Chrome二进制位置。
caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"binary" => "Actual Path"})