GithubHelp home page GithubHelp logo

mifrill / ruby-chromedriver Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nbulaj/ruby-chromedriver

0.0 2.0 0.0 14 KB

Ruby 2.4, Chrome / Chrome driver, NodeJS on Docker for Cucumber specs

License: MIT License

Shell 100.00%

ruby-chromedriver's Introduction

ruby-chromedriver

Docker Pulls Docker Stars

Ruby 2.4, Chrome / Chrome driver, NodeJS on Docker for Capybara/Cucumber specs.

Based on official Ruby 2.4 image and uses official stable Chrome repository. Uses X virtual framebuffer (Xvfb) for keycode conversions.

Can be used for Continuous Integration or Delivery (CI/CD) pipelines (like GitLab) instead of Qt and PhantomJS:

Configuration

GitLab CI configuration for Ruby on Rails project + Cucumber using the image (read https://about.gitlab.com/2017/12/19/moving-to-headless-chrome/):

cucumber:
  stage: test
  image: 'nbulai/ruby-chromedriver:latest'
  variables:
    RAILS_ENV: test
  script:
    - chromedriver -v # to check version
    - ...
    - bin/cucumber
  artifacts:
    paths:
      - coverage/
  only:
    - master

Don't forget to configure your Cucumber/Capybara to use Chrome as a driver.

First install it locally to run your test-suite (if you will run tests on the dev machine):

# add Google public key
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
# add Google Chrome stable repository to sources
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
sudo apt-get update 
# install Chrome and it's driver
sudo apt-get install google-chrome-stable chromium-chromedriver
sudo ln -s /usr/lib/chromium-browser/chromedriver /usr/bin/chromedriver
# check if all is OK
chromedriver -v

Add gem selenium-webdriver to your Gemfile:

group :test do
  # ...
  gem 'selenium-webdriver'
end

And then edit features/support/env.rb (or other config file):

# ...

Capybara.register_driver(:headless_chrome) do |app|
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
    # Add 'no-sandbox' arg if you have an "unknown error: Chrome failed to start: exited abnormally"
    # @see https://github.com/SeleniumHQ/selenium/issues/4961
    chromeOptions: { args: %w[headless disable-gpu no-sandbox] } 
  )

  Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities)
end

Capybara.javascript_driver = :headless_chrome

# ...

That's all. Run bin/cucumber to check your tests.

License

This repo content is released under the MIT License.

Copyright (c) 2017-2018 Nikita Bulai ([email protected]).

ruby-chromedriver's People

Contributors

nbulaj avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.