Method: Ferrum::Browser::Process#initialize
- Defined in:
- lib/ferrum/browser/process.rb
#initialize(options) ⇒ Process
Returns a new instance of Process.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/ferrum/browser/process.rb', line 101 def initialize() @options = {} @path = [:browser_path] || BROWSER_PATH || self.class.detect_browser_path if [:url] url = URI.join([:url].to_s, "/json/version") response = JSON.parse(::Net::HTTP.get(url)) set_ws_url(response["webSocketDebuggerUrl"]) return end # Doesn't work on MacOS, so we need to set it by CDP as well @options.merge!("window-size" => [:window_size].join(",")) port = .fetch(:port, BROWSER_PORT) @options.merge!("remote-debugging-port" => port) host = .fetch(:host, BROWSER_HOST) @options.merge!("remote-debugging-address" => host) @options.merge!("user-data-dir" => Dir.mktmpdir) @options = DEFAULT_OPTIONS.merge(@options) unless .fetch(:headless, true) @options.delete("headless") @options.delete("disable-gpu") end @process_timeout = .fetch(:process_timeout, PROCESS_TIMEOUT) @options.merge!(.fetch(:browser_options, {})) @logger = [:logger] end |