Class: Puppeteer::Launcher::BrowserOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/puppeteer/launcher/browser_options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ BrowserOptions

Returns a new instance of BrowserOptions.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/puppeteer/launcher/browser_options.rb', line 29

def initialize(options)
  @ignore_https_errors = options[:ignore_https_errors] || false
  # `default_viewport: nil` must be respected here.
  @default_viewport = options.key?(:default_viewport) ? options[:default_viewport] : Puppeteer::Viewport.new(width: 800, height: 600)
  @slow_mo = options[:slow_mo] || 0
  @network_enabled = options.fetch(:network_enabled, true)
  @issues_enabled = options.fetch(:issues_enabled, true)
  @protocol_timeout = options[:protocol_timeout]
  @block_list = options[:block_list]
  if @block_list && !@block_list.is_a?(Array)
    raise ArgumentError.new('block_list must be an Array of URL patterns')
  end

  # only for Puppeteer.connect
  @target_filter = options[:target_filter]
  if @target_filter && !@target_filter.respond_to?(:call)
    raise ArgumentError.new('target_filter must be a Proc (target_info => true/false)')
  end

  @is_page_target = options[:is_page_target]
  if @is_page_target && !@is_page_target.respond_to?(:call)
    raise ArgumentError.new('is_page_target must be a Proc (target_info => true/false)')
  end
end

Instance Attribute Details

#block_listObject (readonly)

Returns the value of attribute block_list.



54
55
56
# File 'lib/puppeteer/launcher/browser_options.rb', line 54

def block_list
  @block_list
end

#default_viewportObject (readonly)

Returns the value of attribute default_viewport.



54
55
56
# File 'lib/puppeteer/launcher/browser_options.rb', line 54

def default_viewport
  @default_viewport
end

#is_page_targetObject (readonly)

Returns the value of attribute is_page_target.



54
55
56
# File 'lib/puppeteer/launcher/browser_options.rb', line 54

def is_page_target
  @is_page_target
end

#issues_enabledObject (readonly)

Returns the value of attribute issues_enabled.



54
55
56
# File 'lib/puppeteer/launcher/browser_options.rb', line 54

def issues_enabled
  @issues_enabled
end

#network_enabledObject (readonly)

Returns the value of attribute network_enabled.



54
55
56
# File 'lib/puppeteer/launcher/browser_options.rb', line 54

def network_enabled
  @network_enabled
end

#protocol_timeoutObject (readonly)

Returns the value of attribute protocol_timeout.



54
55
56
# File 'lib/puppeteer/launcher/browser_options.rb', line 54

def protocol_timeout
  @protocol_timeout
end

#slow_moObject (readonly)

Returns the value of attribute slow_mo.



54
55
56
# File 'lib/puppeteer/launcher/browser_options.rb', line 54

def slow_mo
  @slow_mo
end

#target_filterObject (readonly)

Returns the value of attribute target_filter.



54
55
56
# File 'lib/puppeteer/launcher/browser_options.rb', line 54

def target_filter
  @target_filter
end

Instance Method Details

#ignore_https_errors?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/puppeteer/launcher/browser_options.rb', line 56

def ignore_https_errors?
  @ignore_https_errors
end