【问题标题】:Travis: Unable to find chromedriver特拉维斯:找不到 chromedriver
【发布时间】:2017-02-13 17:48:42
【问题描述】:

我正在尝试使用 watir 将 travis 集成到我的黄瓜测试中。但是,现在,我似乎陷入了 chromedriver 的最后一个问题。我得到了错误

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.

(Selenium::WebDriver::Error::WebDriverError)

我通过在rubylib 文件夹中添加chromedriver 并添加system32, webem 的路径,在我的本地Windows 机器中修复了这个问题

我不确定如何在Travis 中解决此问题。有人可以帮我吗?

我的 .travis.yml 文件如下所示

sudo: required
language: ruby
cache: bundler

rvm: 2.2

 before_script:
    - bundle install
    - gem install watir
    - gem install colorize
    - gem install rspec
    - gem install cucumber
script: bundle exec cucumber

branches:
only:
- master

notifications:
email:
- iamsmj@gmail.com

我已将以下代码添加到现有的 .yml 中

插件: 易于: 包: - 铬浏览器 - 铬铬驱动程序

rvm:2.2

before_script:
    - bundle install
    - gem install watir
    - gem install colorize
    - gem install rspec
    - gem install cucumber
    - wget http://chromedriver.storage.googleapis.com/2.21/chromedriver_linux64.zip
      - unzip chromedriver_linux64.zip
      - sudo chmod u+x chromedriver
      - sudo mv chromedriver /usr/bin/
      - export CHROME_BIN=chromium-browser
      - "export DISPLAY=:99.0"
      - "sh -e /etc/init.d/xvfb start"
      - sleep 3
      - ./travis_before_install

我现在得到的错误是

    --2017-02-13 18:04:46--  http://chromedriver.storage.googleapis.com/2.21/chromedriver_linux64.zip
    Resolving chromedriver.storage.googleapis.com (chromedriver.storage.googleapis.com)... 64.233.191.128, 2607:f8b0:4001:c0c::80
    Connecting to chromedriver.storage.googleapis.com (chromedriver.storage.googleapis.com)|64.233.191.128|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 2692616 (2.6M) [application/zip]
    Saving to: `chromedriver_linux64.zip'
     0% [                                       ] 0           --.-K/s                100%[======================================>] 2,692,616   --.-K/s   in 0.009s  



    wget: unable to resolve host address `.'
    FINISHED --2017-02-13 18:04:48--
    Total wall clock time: 1.5s
    Downloaded: 1 files, 2.6M in 0.009s (281 MB/s)
    The command "wget http://chromedriver.storage.googleapis.com/2.21/chromedriver_linux64.zip - unzip chromedriver_linux64.zip - sudo chmod u+x chromedriver - sudo mv chromedriver /usr/bin/ - export CHROME_BIN=chromium-browser - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" - sleep 3 - ./travis_before_install" failed and exited with 4 during .
    Your build has been stopped.


Also, Could someone please let me know, why travis wouldnt run this?

`The command "bundle exec cucumber" exited with 2.`


UPDATE: I updated the file fixing the indentation in the `before_script` . The latest error i get is 

    0.08s$ unzip chromedriver_linux64.zip
   Archive:  chromedriver_linux64.zip
  inflating: chromedriver            
   before_script.10
   0.01s$ sudo chmod u+x chromedriver
   before_script.11
   0.01s$ sudo mv chromedriver /usr/bin/
   before_script.12
   0.00s$ export CHROME_BIN=chromium-browser
   before_script.13
   0.00s$ export DISPLAY=:99.0
   before_script.14
   0.01s$ sh -e /etc/init.d/xvfb start
   Starting virtual X frame buffer: Xvfb.
   before_script.15
   3.01s$ sleep 3
   2.55s$ bundle exec cucumber
   end of file reached (EOFError)
   The command "bundle exec cucumber" exited with 2.
Done. Your build exited with 1. 


     **Update:** I tried fixing up the identation errors in the script as. The new error i get is 

     0% [                                       ] 0           --.-K/s                  100%[======================================>] 2,692,616   --.-K/s   in 0.01s   
   2017-02-14 11:00:45 (173 MB/s) - ‘chromedriver_linux64.zip’ saved    [2692616/2692616]
    before_script.9
   0.08s$ unzip chromedriver_linux64.zip
   Archive:  chromedriver_linux64.zip
   inflating: chromedriver            
    before_script.10
   0.01s$ sudo chmod u+x chromedriver
   before_script.11
   0.01s$ sudo mv chromedriver /usr/bin/
   before_script.12
   0.00s$ export CHROME_BIN=chromium-browser
   before_script.13
   0.00s$ export DISPLAY=:99.0
   before_script.14
   0.01s$ sh -e /etc/init.d/xvfb start
   Starting virtual X frame buffer: Xvfb.
   before_script.15
   3.01s$ sleep 3
   2.55s$ bundle exec cucumber
   **end of file reached (EOFError)**
   The command "bundle exec cucumber" exited with 2.
    Done. Your build exited with 1.

【问题讨论】:

  • 您是否尝试在脚本中明确设置? Selenium::WebDriver::Chrome::Service.executable_path = '/usr/bin/chromedriver'
  • @Raphael 不!没有!你能告诉我我在哪里必须提到这段代码吗?是在before_script吗?
  • 能否修复before_script 阶段的缩进并再次运行构建?
  • 好的! @joepd:现在有一些进展。我已经更新了我的问题。请看一下

标签: ruby continuous-integration cucumber travis-ci


【解决方案1】:

最后,能够让 travis 运行我的黄瓜测试。

我所做的改变

  1. 为过去显示Not permitted的权限更改提供了sudo
  2. 将 Chrome 驱动程序版本从 2.7 降级为 2.27

这些修复了它

当前.travis.yml 文件如下所示

sudo: required
language: ruby

dist: trusty

addons:
  apt:
    sources:
       - google-chrome
    packages:
    - google-chrome-stable


 script: bundle exec cucumber


 before_script:
    - bundle install
    - gem install watir
    - gem install colorize
    - gem install rspec
    - gem install cucumber
    - gem install rake
    - gem install chromium
    - wget http://chromedriver.storage.googleapis.com/2.27/chromedriver_linux64.zip
    - unzip chromedriver_linux64.zip
    - sudo apt-get install libnss3
    - sudo apt-get --only-upgrade install google-chrome-stable
    - sudo cp chromedriver /usr/local/bin/.
    - sudo chmod +x /usr/local/bin/chromedriver
    - export DISPLAY=:99.0
    - sh -e /etc/init.d/xvfb start
    - sleep 3


branches:
 only:
  - master

notifications:
 email:
- iamsmj@gmail.com

【讨论】:

    【解决方案2】:

    我自己尝试了您的解决方案,因为我遇到了同样的错误,但没有成功。结合the docsthis SO 答案后,我最终得到了这个设置,它有效:

    dist: trusty
    
    language: ruby
    
    sudo: required
    
    before_install:
      - gem install bundler
      - "rm ${BUNDLE_GEMFILE}.lock"
      - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
    
    cache: bundler
    
    rvm:
     - 2.4.0
    
    env:
     - DB=pgsql
    
    services:
     - postgresql
    
    test:
      adapter: postgresql
      database: app_test
    
    addons:
      chrome: stable
    
    # uncomment and edit the following line if your project needs to run something other than `rake`:
    # script: 
    # - bundle exec rspec spec
    
    before_script:
     - cp config/database.yml.travis config/database.yml
     - psql -c 'create database app_test;' -U postgres
     - bundle update
     - bundle exec rake db:test:prepare
     - export DISPLAY=:99.0
     - sh -e /etc/init.d/xvfb start
     - sleep 3
    
    deploy:
      provider: heroku
      api_key:
        secure: "api_ley"
      app: awesome-development-app
    
    notifications:
      slack: app:key
    

    重要的步骤是: google-chrome-stablebefore_installaddons - chrome - stableDISPLAY 值中。

    也许它对某人有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-12
      • 2015-02-20
      • 1970-01-01
      • 2021-09-02
      • 1970-01-01
      • 2019-12-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多