Class: Html2rss::RequestService::PuppetCommander::PreloadRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/request_service/puppet_commander/preload_runner.rb

Overview

Runs Browserless preload choreography: wait, click, and scroll against the interaction budget on Context#budget.

Instance Method Summary collapse

Constructor Details

#initialize(ctx:) ⇒ PreloadRunner

Returns a new instance of PreloadRunner.

Parameters:

  • ctx (Context)

    request context providing preload config and budget



12
13
14
# File 'lib/html2rss/request_service/puppet_commander/preload_runner.rb', line 12

def initialize(ctx:)
  @ctx = ctx
end

Instance Method Details

#call(page) ⇒ void

This method returns an undefined value.

Executes configured preload actions on the page, if any.

Parameters:

  • page (Puppeteer::Page)

    browser page after initial navigation



21
22
23
24
25
26
27
28
29
# File 'lib/html2rss/request_service/puppet_commander/preload_runner.rb', line 21

def call(page)
  preload_config = ctx.browserless_preload
  return unless preload_config

  wait_after(page, preload_config[:wait_after_ms])
  click_selectors(page, preload_config[:click_selectors]) if preload_config[:click_selectors]
  scroll_down(page, preload_config[:scroll_down]) if preload_config[:scroll_down]
  wait_after(page, preload_config[:wait_after_ms])
end