puppeteer-ruby 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +71 -0
  3. data/.github/stale.yml +16 -0
  4. data/.gitignore +19 -0
  5. data/.rspec +3 -0
  6. data/.rubocop.yml +302 -0
  7. data/.travis.yml +7 -0
  8. data/Dockerfile +6 -0
  9. data/Gemfile +6 -0
  10. data/README.md +54 -0
  11. data/Rakefile +1 -0
  12. data/bin/console +11 -0
  13. data/bin/setup +8 -0
  14. data/docker-compose.yml +15 -0
  15. data/docs/Puppeteer.html +2020 -0
  16. data/docs/Puppeteer/AsyncAwaitBehavior.html +105 -0
  17. data/docs/Puppeteer/Browser.html +2148 -0
  18. data/docs/Puppeteer/BrowserContext.html +809 -0
  19. data/docs/Puppeteer/BrowserFetcher.html +214 -0
  20. data/docs/Puppeteer/BrowserRunner.html +914 -0
  21. data/docs/Puppeteer/BrowserRunner/BrowserProcess.html +477 -0
  22. data/docs/Puppeteer/CDPSession.html +813 -0
  23. data/docs/Puppeteer/CDPSession/Error.html +124 -0
  24. data/docs/Puppeteer/ConcurrentRubyUtils.html +430 -0
  25. data/docs/Puppeteer/Connection.html +960 -0
  26. data/docs/Puppeteer/Connection/MessageCallback.html +434 -0
  27. data/docs/Puppeteer/Connection/ProtocolError.html +216 -0
  28. data/docs/Puppeteer/Connection/RequestDebugPrinter.html +217 -0
  29. data/docs/Puppeteer/Connection/ResponseDebugPrinter.html +244 -0
  30. data/docs/Puppeteer/ConsoleMessage.html +565 -0
  31. data/docs/Puppeteer/ConsoleMessage/Location.html +433 -0
  32. data/docs/Puppeteer/DOMWorld.html +2219 -0
  33. data/docs/Puppeteer/DOMWorld/DetachedError.html +124 -0
  34. data/docs/Puppeteer/DOMWorld/DocumentEvaluationError.html +124 -0
  35. data/docs/Puppeteer/DebugPrint.html +233 -0
  36. data/docs/Puppeteer/Device.html +470 -0
  37. data/docs/Puppeteer/Devices.html +139 -0
  38. data/docs/Puppeteer/ElementHandle.html +2542 -0
  39. data/docs/Puppeteer/ElementHandle/ElementNotFoundError.html +206 -0
  40. data/docs/Puppeteer/ElementHandle/ElementNotVisibleError.html +206 -0
  41. data/docs/Puppeteer/ElementHandle/Point.html +492 -0
  42. data/docs/Puppeteer/ElementHandle/ScrollIntoViewError.html +124 -0
  43. data/docs/Puppeteer/EmulationManager.html +454 -0
  44. data/docs/Puppeteer/EventCallbackable.html +433 -0
  45. data/docs/Puppeteer/EventCallbackable/EventListeners.html +435 -0
  46. data/docs/Puppeteer/ExecutionContext.html +998 -0
  47. data/docs/Puppeteer/ExecutionContext/EvaluationError.html +124 -0
  48. data/docs/Puppeteer/ExecutionContext/JavaScriptExpression.html +357 -0
  49. data/docs/Puppeteer/ExecutionContext/JavaScriptFunction.html +389 -0
  50. data/docs/Puppeteer/FileChooser.html +455 -0
  51. data/docs/Puppeteer/Frame.html +3677 -0
  52. data/docs/Puppeteer/FrameManager.html +2410 -0
  53. data/docs/Puppeteer/FrameManager/NavigationError.html +124 -0
  54. data/docs/Puppeteer/IfPresent.html +222 -0
  55. data/docs/Puppeteer/JSHandle.html +1352 -0
  56. data/docs/Puppeteer/Keyboard.html +1557 -0
  57. data/docs/Puppeteer/Keyboard/KeyDefinition.html +831 -0
  58. data/docs/Puppeteer/Keyboard/KeyDescription.html +603 -0
  59. data/docs/Puppeteer/Launcher.html +237 -0
  60. data/docs/Puppeteer/Launcher/Base.html +385 -0
  61. data/docs/Puppeteer/Launcher/Base/ExecutablePathNotFound.html +124 -0
  62. data/docs/Puppeteer/Launcher/BrowserOptions.html +441 -0
  63. data/docs/Puppeteer/Launcher/Chrome.html +669 -0
  64. data/docs/Puppeteer/Launcher/Chrome/DefaultArgs.html +382 -0
  65. data/docs/Puppeteer/Launcher/ChromeArgOptions.html +531 -0
  66. data/docs/Puppeteer/Launcher/LaunchOptions.html +893 -0
  67. data/docs/Puppeteer/LifecycleWatcher.html +834 -0
  68. data/docs/Puppeteer/LifecycleWatcher/ExpectedLifecycle.html +363 -0
  69. data/docs/Puppeteer/LifecycleWatcher/FrameDetachedError.html +206 -0
  70. data/docs/Puppeteer/LifecycleWatcher/TerminatedError.html +124 -0
  71. data/docs/Puppeteer/Mouse.html +1105 -0
  72. data/docs/Puppeteer/Mouse/Button.html +136 -0
  73. data/docs/Puppeteer/NetworkManager.html +901 -0
  74. data/docs/Puppeteer/NetworkManager/Credentials.html +385 -0
  75. data/docs/Puppeteer/Page.html +5970 -0
  76. data/docs/Puppeteer/Page/FileChooserTimeoutError.html +206 -0
  77. data/docs/Puppeteer/Page/ScreenshotOptions.html +845 -0
  78. data/docs/Puppeteer/Page/ScriptTag.html +555 -0
  79. data/docs/Puppeteer/Page/StyleTag.html +448 -0
  80. data/docs/Puppeteer/Page/TargetCrashedError.html +124 -0
  81. data/docs/Puppeteer/RemoteObject.html +1087 -0
  82. data/docs/Puppeteer/Target.html +1336 -0
  83. data/docs/Puppeteer/Target/InitializeFailure.html +124 -0
  84. data/docs/Puppeteer/Target/TargetInfo.html +729 -0
  85. data/docs/Puppeteer/TimeoutError.html +135 -0
  86. data/docs/Puppeteer/TimeoutSettings.html +496 -0
  87. data/docs/Puppeteer/TouchScreen.html +464 -0
  88. data/docs/Puppeteer/Viewport.html +837 -0
  89. data/docs/Puppeteer/WaitTask.html +637 -0
  90. data/docs/Puppeteer/WaitTask/TerminatedError.html +124 -0
  91. data/docs/Puppeteer/WaitTask/TimeoutError.html +206 -0
  92. data/docs/Puppeteer/WebSocket.html +673 -0
  93. data/docs/Puppeteer/WebSocket/DriverImpl.html +412 -0
  94. data/docs/Puppeteer/WebSocketTransport.html +600 -0
  95. data/docs/Puppeteer/WebSocktTransportError.html +124 -0
  96. data/docs/_index.html +823 -0
  97. data/docs/class_list.html +51 -0
  98. data/docs/css/common.css +1 -0
  99. data/docs/css/full_list.css +58 -0
  100. data/docs/css/style.css +496 -0
  101. data/docs/file.README.html +123 -0
  102. data/docs/file_list.html +56 -0
  103. data/docs/frames.html +17 -0
  104. data/docs/index.html +123 -0
  105. data/docs/js/app.js +314 -0
  106. data/docs/js/full_list.js +216 -0
  107. data/docs/js/jquery.js +4 -0
  108. data/docs/method_list.html +4075 -0
  109. data/docs/top-level-namespace.html +126 -0
  110. data/lib/puppeteer.rb +200 -0
  111. data/lib/puppeteer/async_await_behavior.rb +38 -0
  112. data/lib/puppeteer/browser.rb +259 -0
  113. data/lib/puppeteer/browser_context.rb +90 -0
  114. data/lib/puppeteer/browser_fetcher.rb +6 -0
  115. data/lib/puppeteer/browser_runner.rb +161 -0
  116. data/lib/puppeteer/cdp_session.rb +100 -0
  117. data/lib/puppeteer/concurrent_ruby_utils.rb +37 -0
  118. data/lib/puppeteer/connection.rb +254 -0
  119. data/lib/puppeteer/console_message.rb +24 -0
  120. data/lib/puppeteer/debug_print.rb +20 -0
  121. data/lib/puppeteer/device.rb +12 -0
  122. data/lib/puppeteer/devices.rb +885 -0
  123. data/lib/puppeteer/dom_world.rb +484 -0
  124. data/lib/puppeteer/element_handle.rb +433 -0
  125. data/lib/puppeteer/element_handle/bounding_box.rb +12 -0
  126. data/lib/puppeteer/element_handle/box_model.rb +19 -0
  127. data/lib/puppeteer/element_handle/point.rb +26 -0
  128. data/lib/puppeteer/emulation_manager.rb +46 -0
  129. data/lib/puppeteer/errors.rb +2 -0
  130. data/lib/puppeteer/event_callbackable.rb +88 -0
  131. data/lib/puppeteer/execution_context.rb +254 -0
  132. data/lib/puppeteer/file_chooser.rb +29 -0
  133. data/lib/puppeteer/frame.rb +286 -0
  134. data/lib/puppeteer/frame_manager.rb +378 -0
  135. data/lib/puppeteer/if_present.rb +18 -0
  136. data/lib/puppeteer/js_handle.rb +142 -0
  137. data/lib/puppeteer/keyboard.rb +183 -0
  138. data/lib/puppeteer/keyboard/key_description.rb +19 -0
  139. data/lib/puppeteer/keyboard/us_keyboard_layout.rb +283 -0
  140. data/lib/puppeteer/launcher.rb +25 -0
  141. data/lib/puppeteer/launcher/base.rb +48 -0
  142. data/lib/puppeteer/launcher/browser_options.rb +41 -0
  143. data/lib/puppeteer/launcher/chrome.rb +211 -0
  144. data/lib/puppeteer/launcher/chrome_arg_options.rb +49 -0
  145. data/lib/puppeteer/launcher/launch_options.rb +68 -0
  146. data/lib/puppeteer/lifecycle_watcher.rb +171 -0
  147. data/lib/puppeteer/mouse.rb +123 -0
  148. data/lib/puppeteer/network_manager.rb +122 -0
  149. data/lib/puppeteer/page.rb +1065 -0
  150. data/lib/puppeteer/page/screenshot_options.rb +78 -0
  151. data/lib/puppeteer/remote_object.rb +143 -0
  152. data/lib/puppeteer/target.rb +150 -0
  153. data/lib/puppeteer/timeout_settings.rb +15 -0
  154. data/lib/puppeteer/touch_screen.rb +43 -0
  155. data/lib/puppeteer/version.rb +3 -0
  156. data/lib/puppeteer/viewport.rb +54 -0
  157. data/lib/puppeteer/wait_task.rb +188 -0
  158. data/lib/puppeteer/web_socket.rb +122 -0
  159. data/lib/puppeteer/web_socket_transport.rb +49 -0
  160. data/puppeteer-ruby.gemspec +32 -0
  161. metadata +355 -0
@@ -0,0 +1,25 @@
1
+ require_relative './launcher/base'
2
+ require_relative './launcher/browser_options'
3
+ require_relative './launcher/chrome'
4
+ require_relative './launcher/chrome_arg_options'
5
+ require_relative './launcher/launch_options'
6
+
7
+ # https://github.com/puppeteer/puppeteer/blob/master/lib/Launcher.js
8
+ module Puppeteer::Launcher
9
+ # @param {string} projectRoot
10
+ # @param {string} preferredRevision
11
+ # @param {boolean} isPuppeteerCore
12
+ # @param {string=} product
13
+ # @return {!Puppeteer.ProductLauncher}
14
+ module_function def new(project_root:, preferred_revision:, is_puppeteer_core:, product:)
15
+ if product == 'firefox'
16
+ raise NotImplementedError.new('FirefoxLauncher is not implemented yet.')
17
+ end
18
+
19
+ Chrome.new(
20
+ project_root: project_root,
21
+ preferred_revision: preferred_revision,
22
+ is_puppeteer_core: is_puppeteer_core,
23
+ )
24
+ end
25
+ end
@@ -0,0 +1,48 @@
1
+ module Puppeteer::Launcher
2
+ class Base
3
+ # @param {string} projectRoot
4
+ # @param {string} preferredRevision
5
+ def initialize(project_root:, preferred_revision:, is_puppeteer_core:)
6
+ @project_root = project_root
7
+ @preferred_revision = preferred_revision
8
+ @is_puppeteer_core = is_puppeteer_core
9
+ end
10
+
11
+ class ExecutablePathNotFound < StandardError; end
12
+
13
+ # @returns [String] Chrome Executable file path.
14
+ # @raise [ExecutablePathNotFound]
15
+ def resolve_executable_path
16
+ if !@is_puppeteer_core
17
+ # puppeteer-core doesn't take into account PUPPETEER_* env variables.
18
+ executable_path = ENV['PUPPETEER_EXECUTABLE_PATH']
19
+ if FileTest.exist?(executable_path)
20
+ return executable_path
21
+ end
22
+ raise ExecutablePathNotFound.new(
23
+ "Tried to use PUPPETEER_EXECUTABLE_PATH env variable to launch browser but did not find any executable at: #{executablePath}",
24
+ )
25
+ end
26
+
27
+ # temporal logic.
28
+ if RUBY_PLATFORM.include?('darwin') # MacOS
29
+ '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
30
+ else
31
+ '/usr/bin/google-chrome'
32
+ end
33
+
34
+ # const browserFetcher = new BrowserFetcher(launcher._projectRoot);
35
+ # if (!launcher._isPuppeteerCore) {
36
+ # const revision = process.env['PUPPETEER_CHROMIUM_REVISION'];
37
+ # if (revision) {
38
+ # const revisionInfo = browserFetcher.revisionInfo(revision);
39
+ # const missingText = !revisionInfo.local ? 'Tried to use PUPPETEER_CHROMIUM_REVISION env variable to launch browser but did not find executable at: ' + revisionInfo.executablePath : null;
40
+ # return {executablePath: revisionInfo.executablePath, missingText};
41
+ # }
42
+ # }
43
+ # const revisionInfo = browserFetcher.revisionInfo(launcher._preferredRevision);
44
+ # const missingText = !revisionInfo.local ? `Browser is not downloaded. Run "npm install" or "yarn install"` : null;
45
+ # return {executablePath: revisionInfo.executablePath, missingText};
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,41 @@
1
+ # const {
2
+ # ignoreDefaultArgs = false,
3
+ # args = [],
4
+ # dumpio = false,
5
+ # executablePath = null,
6
+ # pipe = false,
7
+ # env = process.env,
8
+ # handleSIGINT = true,
9
+ # handleSIGTERM = true,
10
+ # handleSIGHUP = true,
11
+ # ignoreHTTPSErrors = false,
12
+ # defaultViewport = {width: 800, height: 600},
13
+ # slowMo = 0,
14
+ # timeout = 30000
15
+ # } = options;
16
+ # const {
17
+ # devtools = false,
18
+ # headless = !devtools,
19
+ # args = [],
20
+ # userDataDir = null
21
+ # } = options;
22
+
23
+
24
+ module Puppeteer::Launcher
25
+ class BrowserOptions
26
+ # @property {boolean=} ignoreHTTPSErrors
27
+ # @property {(?Puppeteer.Viewport)=} defaultViewport
28
+ # @property {number=} slowMo
29
+ def initialize(options)
30
+ @ignore_https_errors = options[:ignore_https_errors] || false
31
+ @default_viewport = options[:default_viewport] || Puppeteer::Viewport.new(width: 800, height: 600)
32
+ @slow_mo = options[:slow_mo] || 0
33
+ end
34
+
35
+ attr_reader :default_viewport, :slow_mo
36
+
37
+ def ignore_https_errors?
38
+ @ignore_https_errors
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,211 @@
1
+ require 'tmpdir'
2
+
3
+ # https://github.com/puppeteer/puppeteer/blob/master/lib/Launcher.js
4
+ module Puppeteer::Launcher
5
+ class Chrome < Base
6
+ # @param {!(Launcher.LaunchOptions & Launcher.ChromeArgOptions & Launcher.BrowserOptions)=} options
7
+ # @return {!Promise<!Browser>}
8
+ def launch(options = {})
9
+ @chrome_arg_options = ChromeArgOptions.new(options)
10
+ @launch_options = LaunchOptions.new(options)
11
+ @browser_options = BrowserOptions.new(options)
12
+
13
+ chrome_arguments =
14
+ if !@launch_options.ignore_default_args
15
+ default_args.to_a
16
+ elsif @launch_options.ignore_default_args.is_a?(Enumerable)
17
+ default_args.reject do |arg|
18
+ @launch_options.ignore_default_args.include?(arg)
19
+ end.to_a
20
+ else
21
+ @chrome_arg_options.args.dup
22
+ end
23
+
24
+ #
25
+ # let temporaryUserDataDir = null;
26
+
27
+ if chrome_arguments.none? { |arg| arg.start_with?('--remote-debugging-') }
28
+ if @launch_options.pipe?
29
+ chrome_arguments << '--remote-debugging-pipe'
30
+ else
31
+ chrome_arguments << '--remote-debugging-port=0'
32
+ end
33
+ end
34
+
35
+ temporary_user_data_dir = nil
36
+ if chrome_arguments.none? { |arg| arg.start_with?('--user-data-dir') }
37
+ temporary_user_data_dir = Dir.mktmpdir('puppeteer_dev_profile-')
38
+ chrome_arguments << "--user-data-dir=#{temporary_user_data_dir}"
39
+ end
40
+
41
+ chrome_executable = @launch_options.executable_path || resolve_executable_path
42
+ use_pipe = chrome_arguments.include?('--remote-debugging-pipe')
43
+ runner = Puppeteer::BrowserRunner.new(chrome_executable, chrome_arguments, temporary_user_data_dir)
44
+ runner.start(
45
+ handle_SIGHUP: @launch_options.handle_SIGHUP?,
46
+ handle_SIGTERM: @launch_options.handle_SIGTERM?,
47
+ handle_SIGINT: @launch_options.handle_SIGINT?,
48
+ dumpio: @launch_options.dumpio?,
49
+ env: @launch_options.env,
50
+ pipe: use_pipe,
51
+ )
52
+
53
+ begin
54
+ connection = runner.setup_connection(
55
+ use_pipe: use_pipe,
56
+ timeout: @launch_options.timeout,
57
+ slow_mo: @browser_options.slow_mo,
58
+ preferred_revision: @preferred_revision,
59
+ )
60
+
61
+ browser = Puppeteer::Browser.create(
62
+ connection: connection,
63
+ context_ids: [],
64
+ ignore_https_errors: @browser_options.ignore_https_errors?,
65
+ default_viewport: @browser_options.default_viewport,
66
+ process: runner.proc,
67
+ close_callback: -> { runner.close },
68
+ )
69
+
70
+ browser.wait_for_target(predicate: ->(target) { target.type == 'page' })
71
+
72
+ browser
73
+ rescue
74
+ runner.kill
75
+ raise
76
+ end
77
+ end
78
+
79
+ class DefaultArgs
80
+ include Enumerable
81
+
82
+ # @param options [Launcher::ChromeArgOptions]
83
+ def initialize(chrome_arg_options)
84
+ chrome_arguments = [
85
+ '--disable-background-networking',
86
+ '--enable-features=NetworkService,NetworkServiceInProcess',
87
+ '--disable-background-timer-throttling',
88
+ '--disable-backgrounding-occluded-windows',
89
+ '--disable-breakpad',
90
+ '--disable-client-side-phishing-detection',
91
+ '--disable-component-extensions-with-background-pages',
92
+ '--disable-default-apps',
93
+ '--disable-dev-shm-usage',
94
+ '--disable-extensions',
95
+ '--disable-features=TranslateUI',
96
+ '--disable-hang-monitor',
97
+ '--disable-ipc-flooding-protection',
98
+ '--disable-popup-blocking',
99
+ '--disable-prompt-on-repost',
100
+ '--disable-renderer-backgrounding',
101
+ '--disable-sync',
102
+ '--force-color-profile=srgb',
103
+ '--metrics-recording-only',
104
+ '--no-first-run',
105
+ '--enable-automation',
106
+ '--password-store=basic',
107
+ '--use-mock-keychain',
108
+ ]
109
+
110
+ if chrome_arg_options.user_data_dir
111
+ chrome_arguments << "--user-data-dir=#{chrome_arg_options.user_data_dir}"
112
+ end
113
+
114
+ if chrome_arg_options.devtools?
115
+ chrome_arguments << '--auto-open-devtools-for-tabs'
116
+ end
117
+
118
+ if chrome_arg_options.headless?
119
+ chrome_arguments.concat([
120
+ '--headless',
121
+ '--hide-scrollbars',
122
+ '--mute-audio',
123
+ ])
124
+ end
125
+
126
+ if chrome_arg_options.args.all? { |arg| arg.start_with?('-') }
127
+ chrome_arguments << 'about:blank'
128
+ end
129
+
130
+ chrome_arguments.concat(chrome_arg_options.args)
131
+
132
+ @chrome_arguments = chrome_arguments
133
+ end
134
+
135
+ def each(&block)
136
+ @chrome_arguments.each do |opt|
137
+ block.call(opt)
138
+ end
139
+ end
140
+ end
141
+
142
+ def default_args(options = nil)
143
+ if options.nil?
144
+ @default_args ||= DefaultArgs.new(@chrome_arg_options)
145
+ else
146
+ DefaultArgs.new(ChromeArgOptions.new(options))
147
+ end
148
+ end
149
+
150
+ # @param {!(Launcher.BrowserOptions & {browserWSEndpoint?: string, browserURL?: string, transport?: !Puppeteer.ConnectionTransport})} options
151
+ # @return {!Promise<!Browser>}
152
+ def connect(options = {})
153
+ @browser_options = BrowserOptions.new(options)
154
+ browser_ws_endpoint = options[:browser_ws_endpoint]
155
+ browser_url = options[:browser_url]
156
+ transport = options[:transport]
157
+
158
+ connection =
159
+ if browser_ws_endpoint && browser_url.nil? && transport.nil?
160
+ connect_with_browser_ws_endpoint(browser_ws_endpoint)
161
+ elsif browser_ws_endpoint.nil? && browser_url && transport.nil?
162
+ connect_with_browser_url(browser_url)
163
+ elsif browser_ws_endpoint.nil? && browser_url.nil? && transport
164
+ connect_with_transport(transport)
165
+ else
166
+ raise ArgumentError.new("Exactly one of browserWSEndpoint, browserURL or transport must be passed to puppeteer.connect")
167
+ end
168
+
169
+ result = connection.send_message('Target.getBrowserContexts')
170
+ browser_context_ids = result['browserContextIds']
171
+
172
+ Puppeteer::Browser.create(
173
+ connection: connection,
174
+ context_ids: browser_context_ids,
175
+ ignore_https_errors: @browser_options.ignore_https_errors?,
176
+ default_viewport: @browser_options.default_viewport,
177
+ process: nil,
178
+ close_callback: -> { connection.send_message('Browser.close') },
179
+ )
180
+ end
181
+
182
+ # @return [Puppeteer::Connection]
183
+ private def connect_with_browser_ws_endpoint(browser_ws_endpoint)
184
+ transport = Puppeteer::WebSocketTransport.create(browser_ws_endpoint)
185
+ Puppeteer::Connection.new(browser_ws_endpoint, transport, @browser_options.slow_mo)
186
+ end
187
+
188
+ # @return [Puppeteer::Connection]
189
+ private def connect_with_browser_url(browser_url)
190
+ raise NotImplementedError.new('Puppeteer#connect with browserUrl is not implemented yet.')
191
+ # const connectionURL = await getWSEndpoint(browserURL);
192
+ # const connectionTransport = await WebSocketTransport.create(
193
+ # connectionURL
194
+ # );
195
+ end
196
+
197
+ # @return [Puppeteer::Connection]
198
+ private def connect_with_transport(transport)
199
+ Puppeteer::Connection.new('', transport, @browser_options.slow_mo)
200
+ end
201
+
202
+ # @return {string}
203
+ def executable_path
204
+ resolve_executable_path
205
+ end
206
+
207
+ private def product
208
+ 'chrome'
209
+ end
210
+ end
211
+ end
@@ -0,0 +1,49 @@
1
+ # const {
2
+ # ignoreDefaultArgs = false,
3
+ # args = [],
4
+ # dumpio = false,
5
+ # executablePath = null,
6
+ # pipe = false,
7
+ # env = process.env,
8
+ # handleSIGINT = true,
9
+ # handleSIGTERM = true,
10
+ # handleSIGHUP = true,
11
+ # ignoreHTTPSErrors = false,
12
+ # defaultViewport = {width: 800, height: 600},
13
+ # slowMo = 0,
14
+ # timeout = 30000
15
+ # } = options;
16
+ # const {
17
+ # devtools = false,
18
+ # headless = !devtools,
19
+ # args = [],
20
+ # userDataDir = null
21
+ # } = options;
22
+
23
+ module Puppeteer::Launcher
24
+ class ChromeArgOptions
25
+ # * @property {boolean=} headless
26
+ # * @property {Array<string>=} args
27
+ # * @property {string=} userDataDir
28
+ # * @property {boolean=} devtools
29
+ def initialize(options)
30
+ @args = options[:args] || []
31
+ @user_data_dir = options[:user_data_dir]
32
+ @devtools = options[:devtools] || false
33
+ @headless = options[:headless]
34
+ if @headless.nil?
35
+ @headless = !@devtools
36
+ end
37
+ end
38
+
39
+ attr_reader :args, :user_data_dir
40
+
41
+ def headless?
42
+ @headless
43
+ end
44
+
45
+ def devtools?
46
+ @devtools
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,68 @@
1
+ # const {
2
+ # ignoreDefaultArgs = false,
3
+ # args = [],
4
+ # dumpio = false,
5
+ # executablePath = null,
6
+ # pipe = false,
7
+ # env = process.env,
8
+ # handleSIGINT = true,
9
+ # handleSIGTERM = true,
10
+ # handleSIGHUP = true,
11
+ # ignoreHTTPSErrors = false,
12
+ # defaultViewport = {width: 800, height: 600},
13
+ # slowMo = 0,
14
+ # timeout = 30000
15
+ # } = options;
16
+ # const {
17
+ # devtools = false,
18
+ # headless = !devtools,
19
+ # args = [],
20
+ # userDataDir = null
21
+ # } = options;
22
+
23
+ module Puppeteer::Launcher
24
+ class LaunchOptions
25
+ # @property {string=} executablePath
26
+ # @property {boolean|Array<string>=} ignoreDefaultArgs
27
+ # @property {boolean=} handleSIGINT
28
+ # @property {boolean=} handleSIGTERM
29
+ # @property {boolean=} handleSIGHUP
30
+ # @property {number=} timeout
31
+ # @property {boolean=} dumpio
32
+ # @property {!Object<string, string | undefined>=} env
33
+ # @property {boolean=} pipe
34
+ def initialize(options)
35
+ @executable_path = options[:executable_path]
36
+ @ignore_default_args = options[:ignore_default_args] || false
37
+ @handle_SIGINT = options[:handle_SIGINT] || true
38
+ @handle_SIGTERM = options[:handle_SIGTERM] || true
39
+ @handle_SIGHUP = options[:handle_SIGHUP] || true
40
+ @timeout = options[:timeout] || 30000
41
+ @dumpio = options[:dumpio] || false
42
+ @env = options[:env] || ENV
43
+ @pipe = options[:pipe] || false
44
+ end
45
+
46
+ attr_reader :executable_path, :ignore_default_args, :timeout, :env
47
+
48
+ def handle_SIGINT?
49
+ @handle_SIGINT
50
+ end
51
+
52
+ def handle_SIGTERM?
53
+ @handle_SIGTERM
54
+ end
55
+
56
+ def handle_SIGHUP?
57
+ @handle_SIGHUP
58
+ end
59
+
60
+ def dumpio?
61
+ @dumpio
62
+ end
63
+
64
+ def pipe?
65
+ @pipe
66
+ end
67
+ end
68
+ end