Class: Puppeteer::Puppeteer
- Inherits:
-
Object
- Object
- Puppeteer::Puppeteer
- Defined in:
- lib/puppeteer/puppeteer.rb
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 ⇒ String
-
#initialize(project_root:, preferred_revision:, is_puppeteer_core:) ⇒ Puppeteer
constructor
A new instance of Puppeteer.
- #launch(product: 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, headless: nil, ignore_https_errors: nil, default_viewport: nil, slow_mo: nil) ⇒ Puppeteer::Browser
- #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
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/puppeteer/puppeteer.rb', line 87 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
161 162 163 |
# File 'lib/puppeteer/puppeteer.rb', line 161 def createBrowserFetcher( = {}) BrowserFetcher.new(@project_root, ) end |
#default_args(args: nil, user_data_dir: nil, devtools: nil, headless: nil) ⇒ Array<String>
149 150 151 152 153 154 155 156 157 |
# File 'lib/puppeteer/puppeteer.rb', line 149 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
135 136 137 |
# File 'lib/puppeteer/puppeteer.rb', line 135 def devices Puppeteer::Devices end |
#executable_path ⇒ String
116 117 118 |
# File 'lib/puppeteer/puppeteer.rb', line 116 def executable_path launcher.executable_path end |
#launch(product: 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, headless: nil, ignore_https_errors: nil, default_viewport: nil, slow_mo: nil) ⇒ Puppeteer::Browser
29 30 31 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 |
# File 'lib/puppeteer/puppeteer.rb', line 29 def launch( product: 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, headless: nil, ignore_https_errors: nil, default_viewport: nil, slow_mo: nil ) = { 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, headless: headless, ignore_https_errors: ignore_https_errors, default_viewport: , slow_mo: slow_mo, } @product_name ||= product browser = launcher.launch() if block_given? begin yield(browser) ensure browser.close end else browser end end |
#product ⇒ String
130 131 132 |
# File 'lib/puppeteer/puppeteer.rb', line 130 def product launcher.product end |