Sha256: 3468ee8014b1e5df9e0c64598cceab42e84d2f80846cff4e2a16998681ecc8b6

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

# Capybara

[Capybara](https://github.com/teamcapybara/capybara) is originally a test
framework for web applications.

When Capybara is in use, a remote browser process is available as a Capybara
session:

```ruby
class DummyWorker < Wayfarer::Worker
  route.to :index

  def index
    browser # => #<Capybara::Session ...>
  end
end
```


## Configuring a driver

1. Install the Capybara driver for the desired user agent.

    For example, to automate Google Chrome with
    [Ferrum](https://github.com/rubycdp/ferrum), install the
    [Cuprite](https://github.com/rubycdp/cuprite) driver:

    === "RubyGems"

        ```ruby
        gem install cuprite
        ```

    === "Bundler"

        ```ruby
        gem "cuprite" # Gemfile
        ```

2. Configure Wayfarer to use the `:capybara` user agent and set the desired
    driver:

    === "Runtime"

        ```ruby
        Wayfarer.config.network.agent = :capybara
        Wayfarer.config.capybara.driver = :cuprite
        ```

    === "Environment variables"

        ```ruby
        WAYFARER_NETWORK_AGENT=capybara
        WAYFARER_CAPYBARA_DRIVER=cuprite
        ```

3. Register the driver:

    ```ruby
    Capybara.javascript_driver = :cuprite

    Capybara.register_driver(:cuprite) do |app|
      # Wayfarer's Ferrum or Selenium options must be passed along manually
      Capybara::Cuprite::Driver.new(app, Wayfare.config.ferrum.options)
    end
    ```

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wayfarer-0.4.1 docs/guides/browser_automation/capybara.md