Class: Puppeteer::Puppeteer
- Inherits:
-
Object
- Object
- Puppeteer::Puppeteer
- Defined in:
- lib/puppeteer/puppeteer.rb
Defined Under Namespace
Classes: NoViewport
Instance Method Summary collapse
- #connect(browser_ws_endpoint: nil, browser_url: nil, transport: nil, ignore_https_errors: nil, default_viewport: nil, slow_mo: nil) ⇒ Puppeteer::Browser
- #createBrowserFetcher(options = {}) ⇒ !BrowserFetcher
- #default_args(args: nil, user_data_dir: nil, devtools: nil, headless: nil) ⇒ Array<String>
- #devices ⇒ Puppeteer::Devices
- #executable_path(channel: nil) ⇒ String
-
#initialize(project_root:, preferred_revision:, is_puppeteer_core:) ⇒ Puppeteer
constructor
A new instance of Puppeteer.
- #launch(product: nil, channel: nil, executable_path: nil, ignore_default_args: nil, handle_SIGINT: nil, handle_SIGTERM: nil, handle_SIGHUP: nil, timeout: nil, dumpio: nil, env: nil, pipe: nil, args: nil, user_data_dir: nil, devtools: nil, debugging_port: nil, headless: nil, ignore_https_errors: nil, default_viewport: NoViewport.new, slow_mo: nil) ⇒ Puppeteer::Browser
- #network_conditions ⇒ Puppeteer::NetworkConditions
- #product ⇒ String
Constructor Details
#initialize(project_root:, preferred_revision:, is_puppeteer_core:) ⇒ Puppeteer
Returns a new instance of Puppeteer.
5 6 7 8 9 |
# File 'lib/puppeteer/puppeteer.rb', line 5 def initialize(project_root:, preferred_revision:, is_puppeteer_core:) @project_root = project_root @preferred_revision = preferred_revision @is_puppeteer_core = is_puppeteer_core end |
Instance Method Details
#connect(browser_ws_endpoint: nil, browser_url: nil, transport: nil, ignore_https_errors: nil, default_viewport: nil, slow_mo: nil) ⇒ Puppeteer::Browser
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/puppeteer/puppeteer.rb', line 97 def connect( browser_ws_endpoint: nil, browser_url: nil, transport: nil, ignore_https_errors: nil, default_viewport: nil, slow_mo: nil ) = { browser_ws_endpoint: browser_ws_endpoint, browser_url: browser_url, transport: transport, ignore_https_errors: ignore_https_errors, default_viewport: , slow_mo: slow_mo, }.compact browser = launcher.connect() if block_given? begin yield(browser) ensure browser.disconnect end else browser end end |
#createBrowserFetcher(options = {}) ⇒ !BrowserFetcher
176 177 178 |
# File 'lib/puppeteer/puppeteer.rb', line 176 def createBrowserFetcher( = {}) BrowserFetcher.new(@project_root, ) end |
#default_args(args: nil, user_data_dir: nil, devtools: nil, headless: nil) ⇒ Array<String>
164 165 166 167 168 169 170 171 172 |
# File 'lib/puppeteer/puppeteer.rb', line 164 def default_args(args: nil, user_data_dir: nil, devtools: nil, headless: nil) = { args: args, user_data_dir: user_data_dir, devtools: devtools, headless: headless, }.compact launcher.default_args() end |
#devices ⇒ Puppeteer::Devices
145 146 147 |
# File 'lib/puppeteer/puppeteer.rb', line 145 def devices Puppeteer::Devices end |
#executable_path(channel: nil) ⇒ String
126 127 128 |
# File 'lib/puppeteer/puppeteer.rb', line 126 def executable_path(channel: nil) launcher.executable_path(channel: channel) end |
#launch(product: nil, channel: nil, executable_path: nil, ignore_default_args: nil, handle_SIGINT: nil, handle_SIGTERM: nil, handle_SIGHUP: nil, timeout: nil, dumpio: nil, env: nil, pipe: nil, args: nil, user_data_dir: nil, devtools: nil, debugging_port: nil, headless: nil, ignore_https_errors: nil, default_viewport: NoViewport.new, slow_mo: nil) ⇒ Puppeteer::Browser
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/puppeteer/puppeteer.rb', line 32 def launch( product: nil, channel: nil, executable_path: nil, ignore_default_args: nil, handle_SIGINT: nil, handle_SIGTERM: nil, handle_SIGHUP: nil, timeout: nil, dumpio: nil, env: nil, pipe: nil, args: nil, user_data_dir: nil, devtools: nil, debugging_port: nil, headless: nil, ignore_https_errors: nil, default_viewport: NoViewport.new, slow_mo: nil ) = { channel: channel&.to_s, executable_path: executable_path, ignore_default_args: ignore_default_args, handle_SIGINT: handle_SIGINT, handle_SIGTERM: handle_SIGTERM, handle_SIGHUP: handle_SIGHUP, timeout: timeout, dumpio: dumpio, env: env, pipe: pipe, args: args, user_data_dir: user_data_dir, devtools: devtools, debugging_port: debugging_port, headless: headless, ignore_https_errors: ignore_https_errors, default_viewport: , slow_mo: slow_mo, } if .is_a?(NoViewport) .delete(:default_viewport) end @product_name = product browser = launcher.launch() if block_given? begin yield(browser) ensure browser.close end else browser end end |
#network_conditions ⇒ Puppeteer::NetworkConditions
155 156 157 |
# File 'lib/puppeteer/puppeteer.rb', line 155 def network_conditions Puppeteer::NetworkConditions end |
#product ⇒ String
140 141 142 |
# File 'lib/puppeteer/puppeteer.rb', line 140 def product launcher.product end |