Sha256: a53604838befd10b83b04fa736fd57768e578021301aec02e877af34a745dfa9

Contents?: true

Size: 846 Bytes

Versions: 5

Compression:

Stored size: 846 Bytes

Contents

# Consent Screens

Some websites have nag-screens that make visitors wait for a button to show up.
Here is an example with Ferrum where the opt-in button is contained in an
iframe, clicked, and makes the live page behind the screen accessible to
`#index`:

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

class DummyJob < Wayfarer::Base
  route { to :index, host: "example.com" }

  before_action if: :consent_required? do
    sleep(5) # If the consent form has a loading animation
    consent_button&.click
    sleep(5) # Wait for browser to get redirected behind nag-screen
  end

  def index
    # Nag-screen passed
    stage page(live: true).meta.links.internal
  end

  private

  def consent_button
    browser.frames.third.css("button#consent")&.first
  end

  def consent_required?
    browser.css(".consent_screen").any?
  end
end

```

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wayfarer-0.4.6 docs/cookbook/consent_screen.md
wayfarer-0.4.5 docs/cookbook/consent_screen.md
wayfarer-0.4.4 docs/cookbook/consent_screen.md
wayfarer-0.4.3 docs/cookbook/consent_screen.md
wayfarer-0.4.2 docs/cookbook/consent_screen.md