简体   繁体   English

通过xvfb-run运行硒红宝石脚本时出错

[英]Error running selenium ruby script through xvfb-run

What I'm trying to do 我想做什么

Use selenium and its ruby bindings to open chrome and read a value from the DOM. 使用硒及其红宝石绑定来打开chrome并从DOM中读取一个值。 This portion works great however I need to run it on a linux server headlessly. 这部分效果很好,但是我需要在Linux服务器上无头运行它。 Seemed easy enough so I ran it using xvfb-run using this command: 看起来很简单,所以我使用以下命令使用xvfb-run来运行它:

export PATH=$PATH:./bin
xvfb-run --server-arg="-screen 0, 1024x768x16" ruby script.rb

The first line adds the binary chromedriver to PATH and the second lines runs the script through xvfb . 第一行将二进制chromedriver添加到PATH ,第二行通过xvfb运行脚本。 I got this working on an EC2 ubuntu box which is essentially a dev box. 我在EC2 ubuntu盒上进行了工作,这实际上是一个开发盒。 Everything is great. 一切都很棒。

Now comes time to run it on another EC2 ubuntu box using the same bash script. 现在是时候使用相同的bash脚本在另一个EC2 Ubuntu盒子上运行它了。 It spits out an error that the chromedriver binary couldn't be found. 它吐出一个错误, chromedriver二进制文件。 Odd since it worked fine on the other box. 奇怪,因为它在另一个盒子上工作正常。 I checked, the binary is there. 我检查过,二进制文件在那里。 I manually add it to the path and run the bash script again, same error. 我手动将其添加到路径并再次运行bash脚本,同样的错误。 After some troubleshooting and googling I found this: 经过一些故障排除和谷歌搜索,我发现了这一点:

https://code.google.com/p/selenium/wiki/ChromeDriver https://code.google.com/p/selenium/wiki/ChromeDriver

This advises that the chromedriver needs to be symlink'd to /usr/bin/google-chrome . 这建议chromedriver需要符号链接到/usr/bin/google-chrome Again odd since it works fine on the other box and my local machine without this symlink. 再次奇怪,因为在没有此符号链接的情况下,在其他机器和我的本地计算机上也可以正常工作。 I symlinked it to this location and now this is the error I'm getting: 我将其链接到此位置,现在这是我得到的错误:

/usr/local/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.41.0/lib/selenium/webdriver/remote/response.rb:51:in `assert_ok': unknown error: Chrome failed to start: exited abnormally (Selenium::WebDriver::Error::UnknownError)

I've never gotten this on my local or dev box. 我从来没有在我的本地或开发箱上得到这个。 Any ideas? 有任何想法吗? Is this an issue with chromedriver , xvfb or the environment its running in? 这是chromedriverxvfb或其运行环境chromedriver的问题吗? Some difference in the deploy box that would be different than the dev box I'm missing? 部署箱中的某些区别会与我缺少的开发箱不同吗?

I figured this out. 我想通了。 Misunderstanding the directions here . 误会了这里的方向。 Installed google-chrome in /usr/bin and it worked. /usr/bin安装了google-chrome并成功了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM