相关疑难解决方法(0)

无法连接到chromedriver

我使用capybara&selenium测试我的rails项目.当我执行测试脚本时,它有这样的错误

 Selenium::WebDriver::Error::WebDriverError:
   Could not find Firefox binary (os=macosx). Make sure Firefox is installed or set the path manually with Selenium::WebDriver::Firefox::Binary.path=
Run Code Online (Sandbox Code Playgroud)

我谷歌如何使用谷歌浏览器作为测试浏览器而不是Firefox

但它发生其他错误喜欢

Selenium::WebDriver::Error::WebDriverError:
   unable to connect to chromedriver http://127.0.0.1:9515
Run Code Online (Sandbox Code Playgroud)

selenium ruby-on-rails

33
推荐指数
3
解决办法
3万
查看次数

在heroku上使用chrome驱动程序运行selenium:`找不到Chrome二进制文件

我是一个菜鸟,因为它涉及Linux设置(和heroku),所以如果这个问题是基本的道歉.

我想在Heroku上运行selenium webkit(在ruby中).我遇到一个困难,我的脚本无法找到Chrome二进制文件.

我实际上让chrome自己工作:

~ $ chromedriver
Starting ChromeDriver 2.22.397932 (282ed7cf89cf0053b6542e0d0f039d4123bbb6ad) on port 9515
Only local connections are allowed.
Run Code Online (Sandbox Code Playgroud)

chromedriver是我复制的文件/app/vendor/bundle/bin/chromedriver,只是为了让它变得更容易.chromedriver文件存在因为我安装了chromedriver-helper gem.gem应该使二进制文件可用于ruby进程,但没有.

我也尝试过显式设置路径,例如Selenium::WebDriver::Chrome.driver_path = 'chromedriver'在我的ruby代码中,上面提到的文件位于根类别中.

这一切都在当地完美运作(有或没有driver_path)

可能是什么原因?我多年前读过这个SO帖子,但它似乎已经过时了.任何想法将不胜感激!

错误跟踪:

~ $ ruby bin/run.rb
/app/vendor/bundle/ruby/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/response.rb:70:in `assert_ok': unknown error: cannot find Chrome binary (Selenium::WebDriver::Error::UnknownError)
  (Driver info: chromedriver=2.22.397932 (282ed7cf89cf0053b6542e0d0f039d4123bbb6ad),platform=Linux 3.13.0-91-generic x86_64)
    from /app/vendor/bundle/ruby/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/response.rb:34:in `initialize'
    from /app/vendor/bundle/ruby/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/common.rb:78:in `new'
    from /app/vendor/bundle/ruby/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/common.rb:78:in `create_response'
    from /app/vendor/bundle/ruby/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:90:in `request'
    from /app/vendor/bundle/ruby/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
    from /app/vendor/bundle/ruby/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:649:in `raw_execute'
    from /app/vendor/bundle/ruby/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:123:in `create_session' …
Run Code Online (Sandbox Code Playgroud)

ruby linux selenium heroku selenium-webdriver

5
推荐指数
1
解决办法
3816
查看次数

Heroku:使用Selenium时无法找到chromedriver

我有一个Ruby代码,它执行此操作:

browser = Watir::Browser.new(:chrome, switches: switches, headless: true)
browser.goto(....)
Run Code Online (Sandbox Code Playgroud)

当我在Heroku上运行代码时,我得到了

Selenium::WebDriver::Error::WebDriverError:  Unable to find chromedriver. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at https://github
.com/SeleniumHQ/selenium/wiki/ChromeDriver.
Run Code Online (Sandbox Code Playgroud)

我见过像Heroku这样的帖子:使用Watir/Selenium时无法连接到chromedriver 127.0.0.1:9515, 但我不知道如何正确配置buildpacks.我尝试过:

heroku buildpacks:set https://github.com/heroku/heroku-buildpack-google-chrome
heroku buildpacks:set https://github.com/heroku/heroku-buildpack-chromedriver
Run Code Online (Sandbox Code Playgroud)

但是当我尝试将更改推送到Heroku时,我得到:

Error Plugin: chromedriver: files attribute must be specified in /Users/leticia/.local/share/heroku/node_modules/chromedriver/package.json
Run Code Online (Sandbox Code Playgroud)

有人可以一步一步地告诉我如何设置必要的构建包以使Watir gem在Heroku中工作吗?

谢谢

更新:

我需要'网络驱动程序',现在我得到了 Selenium::WebDriver::Error::WebDriverError: unable to connect to chromedriver 127.0.0.1:9515.

我已经尝试将env vars配置为:

ENV['GOOGLE_CHROME_BIN'] = "/app/.apt/opt/google/chrome/chrome"
ENV['GOOGLE_CHROME_SHIM'] = "/app/.apt/usr/bin/google-chrome-stable"
Run Code Online (Sandbox Code Playgroud)

并这样做:

options = …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails webdriver heroku buildpack

5
推荐指数
1
解决办法
753
查看次数

使用带有Heroku Rails Unicorn堆栈的无头浏览器

我看过你可以在Heroku上更改构建的帖子,将PhantomJS与Cedar堆栈一起使用,但是可以在unicorn堆栈上运行无头浏览器吗?

heroku headless-browser phantomjs

3
推荐指数
1
解决办法
1109
查看次数