Sha256: 6f51746db835509bfa045c88dda0da53bba27f713bd9972d71e6aad5d711881e

Contents?: true

Size: 1.51 KB

Versions: 5

Compression:

Stored size: 1.51 KB

Contents

# Selenium

A variety of browsers can be automated using
[Selenium](https://www.selenium.dev).

When Selenium is in use, a remote browser process is accessible within jobs like
so:

```ruby
Wayfarer.config.network.agent = :selenium

class DummyWorker < Wayfarer::Worker
  route { to :index }

  def index
    browser # => #<Selenium::WebDriver ...>
  end
end
```

Using Selenium requires running a [driver](https://www.selenium.dev/downloads)
process.

!!! attention "Fake response header and status code"
    Selenium does not provide response headers or status code.

    Pages retrieved with a Selenium WebDriver return fake values:

    ```ruby
    Wayfarer.config.network.agent = :selenium

    class DummyJob < Wayfarer::Base
      route { to :index }

      def index
        page.headers     # => always {}
        page.status_code # => always 200
      end
    end
    ```

!!! note "Consider using [Ferrum](../ferrum) instead"
    Ferrum provides superior stability and a richer feature set compared to
    Selenium drivers. However Ferrum automates only Google Chrome. Unless a
    different browser is required, consider using Ferrum instead of Selenium.

## Configuring Selenium

=== "Runtime"

    ```ruby
    Wayfarer.config.network.agent = :selenium
    Wayfarer.config.selenium.driver = :firefox
    Wayfarer.config.selenium.options = { url: "http://firefox" }
    ```

=== "Environment variables"

    ```
    WAYFARER_AGENT=selenium
    WAYFARER_SELENIUM_DRIVER=firefox
    WAYFARER_SELENIUM_OPTIONS=url:http://firefox
    ```

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wayfarer-0.4.6 docs/guides/networking/selenium.md
wayfarer-0.4.5 docs/guides/networking/selenium.md
wayfarer-0.4.4 docs/guides/networking/selenium.md
wayfarer-0.4.3 docs/guides/browser_automation/selenium.md
wayfarer-0.4.2 docs/guides/browser_automation/selenium.md