GithubHelp home page GithubHelp logo

ordilei / capybara-box Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wbotelhos/capybara-box

0.0 2.0 0.0 37 KB

:package: Capybara Box - A Tool Box for Capybara

Home Page: http://wbotelhos.com

License: MIT License

Ruby 100.00%

capybara-box's Introduction

Capybara Box

Build Status Gem Version

Configure Capybara with Chrome, Chrome Headless or Firefox with Screenshot feature and Session without losing your mind with just one line.

install

Add the following code on your Gemfile and run bundle install:

group :test do
  gem 'capybara-box', require: false
end

Usage

Just require the lib after Capybara require and you done:

require 'capybara/rails'
require 'capybara-box'

CapybaraBox::Base.configure

By default, chrome is the driver, but you can use chrome_headless and firefox too.

Version

If you do not want install the Chrome Driver on your CI, you can specify the version here and it will be installed automatically for you.

CapybaraBox::Base.configure version: '2.32'
  • This works just for chrome and chrome_headless, for now

Screenshot

You can enable screenshot on failure and send it to S3.

CapybaraBox.configure(
  screenshot: {
    s3: {
      access_key_id:     'KEY',
      bucket:            'bucket',
      secret_access_key: 'SECRET'
    }
  }
)

If you want enable it only on CI, use the enabled option:

CapybaraBox.configure(
  enabled: ENV['CI'],

  screenshot: { // ... }
)

Session

By default, Rack Session manipulation comes as battery, just use it.

page.set_rack_session key: 'value'
page.get_rack_session :key
# 'value'

You can disable this feature using the session option:

CapybaraBox.configure session: false

Add Argument

By default some Switches are enabled for a better performance, you can add yours too:

capybara_box = CapybaraBox.configure

capybara_box.add_argument '--incognito'

Arguments

If you prefere, is possible override all of them:

CapybaraBox.configure arguments: ['--incognito']

Click here to see the avaiables.

Add Preference

By default some Preferences are enabled for a better performance, you can add yours too:

capybara_box = CapybaraBox.configure

capybara_box.add_preference :credentials_enable_service, false

Preferences

If you prefere, is possible override all of them:

CapybaraBox.configure preferences: { credentials_enable_service: false }

You can check Chrome and Firefox.

HTTP Client Options

By default some timeout configs are enabled only on CI env for a better performance. It has this restrition because with timeout enabled, debugger cannot evaluate the variables values. You can override all of them too:

CapybaraBox.configure http_client_options: { read_timeout: 60 }

Driver Options

You can override all driver options:

CapybaraBox.configure driver_options: { clear_local_storage: true }

Log

Log is writen at log/capybara-box.log as default.

You can see each command executed. Time spent between them and debug some hanging command. ๐ŸŽ‰

[15.479][INFO]: RESPONSE Navigate
[15.482][INFO]: COMMAND ExecuteScript {
   "args": [  ],
   "script": "return $(\".gridy\").data(\"ready\")"
}
[15.483][INFO]: Waiting for pending navigations...
[15.545][INFO]: Done waiting for pending navigations. Status: ok

To disable log on CI, for example, use the log options:

CapybaraBox.configure log: ENV['CI'].nil?
  • It works only for chrome and chrome_headless.

Love it!

Via PayPal or Gratipay. Thanks! (:

capybara-box's People

Contributors

wbotelhos 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.