puppeteer-ruby 0.0.13 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +2 -14
- data/.github/workflows/docs.yml +45 -0
- data/.github/workflows/reviewdog.yml +15 -0
- data/.rubocop.yml +39 -3
- data/README.md +54 -1
- data/lib/puppeteer.rb +10 -2
- data/lib/puppeteer/browser.rb +53 -34
- data/lib/puppeteer/browser_context.rb +35 -5
- data/lib/puppeteer/cdp_session.rb +3 -19
- data/lib/puppeteer/concurrent_ruby_utils.rb +6 -0
- data/lib/puppeteer/connection.rb +9 -16
- data/lib/puppeteer/debug_print.rb +1 -1
- data/lib/puppeteer/define_async_method.rb +23 -0
- data/lib/puppeteer/dom_world.rb +84 -73
- data/lib/puppeteer/element_handle.rb +46 -63
- data/lib/puppeteer/emulation_manager.rb +2 -6
- data/lib/puppeteer/env.rb +18 -0
- data/lib/puppeteer/execution_context.rb +1 -6
- data/lib/puppeteer/frame.rb +46 -46
- data/lib/puppeteer/frame_manager.rb +7 -25
- data/lib/puppeteer/js_handle.rb +39 -38
- data/lib/puppeteer/keyboard.rb +9 -29
- data/lib/puppeteer/mouse.rb +20 -24
- data/lib/puppeteer/network_manager.rb +163 -5
- data/lib/puppeteer/page.rb +221 -181
- data/lib/puppeteer/page/pdf_options.rb +166 -0
- data/lib/puppeteer/remote_object.rb +18 -5
- data/lib/puppeteer/request.rb +330 -0
- data/lib/puppeteer/response.rb +113 -0
- data/lib/puppeteer/touch_screen.rb +2 -7
- data/lib/puppeteer/version.rb +1 -1
- data/lib/puppeteer/wait_task.rb +3 -5
- data/lib/puppeteer/web_socket.rb +7 -0
- data/puppeteer-ruby.gemspec +2 -1
- metadata +25 -103
- data/docs/Puppeteer.html +0 -2338
- data/docs/Puppeteer/AsyncAwaitBehavior.html +0 -105
- data/docs/Puppeteer/Browser.html +0 -2258
- data/docs/Puppeteer/BrowserContext.html +0 -809
- data/docs/Puppeteer/BrowserFetcher.html +0 -214
- data/docs/Puppeteer/BrowserRunner.html +0 -914
- data/docs/Puppeteer/BrowserRunner/BrowserProcess.html +0 -477
- data/docs/Puppeteer/CDPSession.html +0 -813
- data/docs/Puppeteer/CDPSession/Error.html +0 -124
- data/docs/Puppeteer/ConcurrentRubyUtils.html +0 -438
- data/docs/Puppeteer/Connection.html +0 -964
- data/docs/Puppeteer/Connection/MessageCallback.html +0 -434
- data/docs/Puppeteer/Connection/ProtocolError.html +0 -216
- data/docs/Puppeteer/Connection/RequestDebugPrinter.html +0 -217
- data/docs/Puppeteer/Connection/ResponseDebugPrinter.html +0 -244
- data/docs/Puppeteer/ConsoleMessage.html +0 -565
- data/docs/Puppeteer/ConsoleMessage/Location.html +0 -433
- data/docs/Puppeteer/DOMWorld.html +0 -2293
- data/docs/Puppeteer/DOMWorld/DetachedError.html +0 -124
- data/docs/Puppeteer/DOMWorld/DocumentEvaluationError.html +0 -124
- data/docs/Puppeteer/DebugPrint.html +0 -233
- data/docs/Puppeteer/Device.html +0 -470
- data/docs/Puppeteer/Devices.html +0 -139
- data/docs/Puppeteer/ElementHandle.html +0 -2542
- data/docs/Puppeteer/ElementHandle/BoundingBox.html +0 -507
- data/docs/Puppeteer/ElementHandle/BoxModel.html +0 -404
- data/docs/Puppeteer/ElementHandle/ElementNotFoundError.html +0 -206
- data/docs/Puppeteer/ElementHandle/ElementNotVisibleError.html +0 -206
- data/docs/Puppeteer/ElementHandle/Point.html +0 -492
- data/docs/Puppeteer/ElementHandle/ScrollIntoViewError.html +0 -124
- data/docs/Puppeteer/EmulationManager.html +0 -454
- data/docs/Puppeteer/EventCallbackable.html +0 -499
- data/docs/Puppeteer/EventCallbackable/EventListeners.html +0 -435
- data/docs/Puppeteer/ExecutionContext.html +0 -998
- data/docs/Puppeteer/ExecutionContext/EvaluationError.html +0 -124
- data/docs/Puppeteer/ExecutionContext/JavaScriptExpression.html +0 -357
- data/docs/Puppeteer/ExecutionContext/JavaScriptFunction.html +0 -389
- data/docs/Puppeteer/FileChooser.html +0 -455
- data/docs/Puppeteer/Frame.html +0 -3835
- data/docs/Puppeteer/FrameManager.html +0 -2410
- data/docs/Puppeteer/FrameManager/NavigationError.html +0 -124
- data/docs/Puppeteer/IfPresent.html +0 -222
- data/docs/Puppeteer/JSHandle.html +0 -1352
- data/docs/Puppeteer/Keyboard.html +0 -1557
- data/docs/Puppeteer/Keyboard/KeyDefinition.html +0 -831
- data/docs/Puppeteer/Keyboard/KeyDescription.html +0 -603
- data/docs/Puppeteer/Launcher.html +0 -237
- data/docs/Puppeteer/Launcher/Base.html +0 -385
- data/docs/Puppeteer/Launcher/Base/ExecutablePathNotFound.html +0 -124
- data/docs/Puppeteer/Launcher/BrowserOptions.html +0 -441
- data/docs/Puppeteer/Launcher/Chrome.html +0 -674
- data/docs/Puppeteer/Launcher/Chrome/DefaultArgs.html +0 -382
- data/docs/Puppeteer/Launcher/ChromeArgOptions.html +0 -531
- data/docs/Puppeteer/Launcher/LaunchOptions.html +0 -893
- data/docs/Puppeteer/LifecycleWatcher.html +0 -834
- data/docs/Puppeteer/LifecycleWatcher/ExpectedLifecycle.html +0 -363
- data/docs/Puppeteer/LifecycleWatcher/FrameDetachedError.html +0 -206
- data/docs/Puppeteer/LifecycleWatcher/TerminatedError.html +0 -124
- data/docs/Puppeteer/Mouse.html +0 -1095
- data/docs/Puppeteer/Mouse/Button.html +0 -136
- data/docs/Puppeteer/NetworkManager.html +0 -901
- data/docs/Puppeteer/NetworkManager/Credentials.html +0 -385
- data/docs/Puppeteer/Page.html +0 -6173
- data/docs/Puppeteer/Page/FileChooserTimeoutError.html +0 -206
- data/docs/Puppeteer/Page/ScreenshotOptions.html +0 -845
- data/docs/Puppeteer/Page/ScriptTag.html +0 -555
- data/docs/Puppeteer/Page/StyleTag.html +0 -448
- data/docs/Puppeteer/Page/TargetCrashedError.html +0 -124
- data/docs/Puppeteer/RemoteObject.html +0 -1087
- data/docs/Puppeteer/Target.html +0 -1336
- data/docs/Puppeteer/Target/InitializeFailure.html +0 -124
- data/docs/Puppeteer/Target/TargetInfo.html +0 -729
- data/docs/Puppeteer/TimeoutError.html +0 -135
- data/docs/Puppeteer/TimeoutSettings.html +0 -496
- data/docs/Puppeteer/TouchScreen.html +0 -464
- data/docs/Puppeteer/Viewport.html +0 -837
- data/docs/Puppeteer/WaitTask.html +0 -637
- data/docs/Puppeteer/WaitTask/TerminatedError.html +0 -124
- data/docs/Puppeteer/WaitTask/TimeoutError.html +0 -206
- data/docs/Puppeteer/WebSocket.html +0 -673
- data/docs/Puppeteer/WebSocket/DriverImpl.html +0 -412
- data/docs/Puppeteer/WebSocket/TransportError.html +0 -124
- data/docs/Puppeteer/WebSocketTransport.html +0 -600
- data/docs/Puppeteer/WebSocktTransportError.html +0 -124
- data/docs/_index.html +0 -816
- data/docs/class_list.html +0 -51
- data/docs/css/common.css +0 -1
- data/docs/css/full_list.css +0 -58
- data/docs/css/style.css +0 -496
- data/docs/file.README.html +0 -125
- data/docs/file_list.html +0 -56
- data/docs/frames.html +0 -17
- data/docs/index.html +0 -125
- data/docs/js/app.js +0 -314
- data/docs/js/full_list.js +0 -216
- data/docs/js/jquery.js +0 -4
- data/docs/method_list.html +0 -4123
- data/docs/top-level-namespace.html +0 -126
- data/lib/puppeteer/async_await_behavior.rb +0 -38
@@ -3,8 +3,9 @@ require_relative './element_handle/box_model'
|
|
3
3
|
require_relative './element_handle/point'
|
4
4
|
|
5
5
|
class Puppeteer::ElementHandle < Puppeteer::JSHandle
|
6
|
+
include Puppeteer::DebugPrint
|
6
7
|
include Puppeteer::IfPresent
|
7
|
-
using Puppeteer::
|
8
|
+
using Puppeteer::DefineAsyncMethod
|
8
9
|
|
9
10
|
# @param context [Puppeteer::ExecutionContext]
|
10
11
|
# @param client [Puppeteer::CDPSession]
|
@@ -23,7 +24,7 @@ class Puppeteer::ElementHandle < Puppeteer::JSHandle
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def content_frame
|
26
|
-
node_info = @remote_object.node_info
|
27
|
+
node_info = @remote_object.node_info(@client)
|
27
28
|
frame_id = node_info['node']['frameId']
|
28
29
|
if frame_id.is_a?(String)
|
29
30
|
@frame_manager.frame(frame_id)
|
@@ -62,7 +63,14 @@ class Puppeteer::ElementHandle < Puppeteer::JSHandle
|
|
62
63
|
end
|
63
64
|
|
64
65
|
def clickable_point
|
65
|
-
result =
|
66
|
+
result =
|
67
|
+
begin
|
68
|
+
@remote_object.content_quads(@client)
|
69
|
+
rescue => err
|
70
|
+
debug_puts(err)
|
71
|
+
nil
|
72
|
+
end
|
73
|
+
|
66
74
|
if !result || result["quads"].empty?
|
67
75
|
raise ElementNotVisibleError.new
|
68
76
|
end
|
@@ -105,11 +113,11 @@ class Puppeteer::ElementHandle < Puppeteer::JSHandle
|
|
105
113
|
end
|
106
114
|
end
|
107
115
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
116
|
+
def hover
|
117
|
+
scroll_into_view_if_needed
|
118
|
+
point = clickable_point
|
119
|
+
@page.mouse.move(point.x, point.y)
|
120
|
+
end
|
113
121
|
|
114
122
|
# @param delay [Number]
|
115
123
|
# @param button [String] "left"|"right"|"middle"
|
@@ -120,12 +128,7 @@ class Puppeteer::ElementHandle < Puppeteer::JSHandle
|
|
120
128
|
@page.mouse.click(point.x, point.y, delay: delay, button: button, click_count: click_count)
|
121
129
|
end
|
122
130
|
|
123
|
-
|
124
|
-
# @param button [String] "left"|"right"|"middle"
|
125
|
-
# @param click_count [Number]
|
126
|
-
async def async_click(delay: nil, button: nil, click_count: nil)
|
127
|
-
click(delay: delay, button: button, click_count: click_count)
|
128
|
-
end
|
131
|
+
define_async_method :async_click
|
129
132
|
|
130
133
|
# @return [Array<String>]
|
131
134
|
def select(*values)
|
@@ -195,17 +198,13 @@ class Puppeteer::ElementHandle < Puppeteer::JSHandle
|
|
195
198
|
@page.touchscreen.tap(point.x, point.y)
|
196
199
|
end
|
197
200
|
|
198
|
-
|
199
|
-
tap
|
200
|
-
end
|
201
|
+
define_async_method :async_tap
|
201
202
|
|
202
203
|
def focus
|
203
204
|
evaluate('element => element.focus()')
|
204
205
|
end
|
205
206
|
|
206
|
-
|
207
|
-
focus
|
208
|
-
end
|
207
|
+
define_async_method :async_focus
|
209
208
|
|
210
209
|
# @param text [String]
|
211
210
|
# @param delay [number|nil]
|
@@ -214,26 +213,17 @@ class Puppeteer::ElementHandle < Puppeteer::JSHandle
|
|
214
213
|
@page.keyboard.type_text(text, delay: delay)
|
215
214
|
end
|
216
215
|
|
217
|
-
|
218
|
-
# @param delay [number|nil]
|
219
|
-
# @return [Future]
|
220
|
-
async def async_type_text(text, delay: nil)
|
221
|
-
type_text(text, delay: delay)
|
222
|
-
end
|
216
|
+
define_async_method :async_type_text
|
223
217
|
|
224
218
|
# @param key [String]
|
219
|
+
# @param text [String]
|
225
220
|
# @param delay [number|nil]
|
226
|
-
def press(key, delay: nil)
|
221
|
+
def press(key, delay: nil, text: nil)
|
227
222
|
focus
|
228
|
-
@page.keyboard.press(key, delay: delay)
|
223
|
+
@page.keyboard.press(key, delay: delay, text: text)
|
229
224
|
end
|
230
225
|
|
231
|
-
|
232
|
-
# @param delay [number|nil]
|
233
|
-
# @return [Future]
|
234
|
-
async def async_press(key, delay: nil)
|
235
|
-
press(key, delay: delay)
|
236
|
-
end
|
226
|
+
define_async_method :async_press
|
237
227
|
|
238
228
|
# @return [BoundingBox|nil]
|
239
229
|
def bounding_box
|
@@ -356,13 +346,7 @@ class Puppeteer::ElementHandle < Puppeteer::JSHandle
|
|
356
346
|
result
|
357
347
|
end
|
358
348
|
|
359
|
-
|
360
|
-
# @param selector [String]
|
361
|
-
# @param page_function [String]
|
362
|
-
# @return [Object]
|
363
|
-
async def async_Seval(selector, page_function, *args)
|
364
|
-
Seval(selector, page_function, *args)
|
365
|
-
end
|
349
|
+
define_async_method :async_Seval
|
366
350
|
|
367
351
|
# `$$eval()` in JavaScript. $ is not allowed to use as a method name in Ruby.
|
368
352
|
# @param selector [String]
|
@@ -379,13 +363,7 @@ class Puppeteer::ElementHandle < Puppeteer::JSHandle
|
|
379
363
|
result
|
380
364
|
end
|
381
365
|
|
382
|
-
|
383
|
-
# @param selector [String]
|
384
|
-
# @param page_function [String]
|
385
|
-
# @return [Object]
|
386
|
-
async def async_SSeval(selector, page_function, *args)
|
387
|
-
SSeval(selector, page_function, *args)
|
388
|
-
end
|
366
|
+
define_async_method :async_SSeval
|
389
367
|
|
390
368
|
# `$x()` in JavaScript. $ is not allowed to use as a method name in Ruby.
|
391
369
|
# @param expression [String]
|
@@ -408,21 +386,26 @@ class Puppeteer::ElementHandle < Puppeteer::JSHandle
|
|
408
386
|
properties.values.map(&:as_element).compact
|
409
387
|
end
|
410
388
|
|
411
|
-
|
412
|
-
|
413
|
-
#
|
414
|
-
#
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
389
|
+
define_async_method :async_Sx
|
390
|
+
|
391
|
+
# in JS, #isIntersectingViewport.
|
392
|
+
# @return [Boolean]
|
393
|
+
def intersecting_viewport?
|
394
|
+
js = <<~JAVASCRIPT
|
395
|
+
async element => {
|
396
|
+
const visibleRatio = await new Promise(resolve => {
|
397
|
+
const observer = new IntersectionObserver(entries => {
|
398
|
+
resolve(entries[0].intersectionRatio);
|
399
|
+
observer.disconnect();
|
400
|
+
});
|
401
|
+
observer.observe(element);
|
402
|
+
});
|
403
|
+
return visibleRatio > 0;
|
404
|
+
}
|
405
|
+
JAVASCRIPT
|
406
|
+
|
407
|
+
evaluate(js)
|
408
|
+
end
|
426
409
|
|
427
410
|
# @param quad [Array<Point>]
|
428
411
|
private def compute_quad_area(quad)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class Puppeteer::EmulationManager
|
2
|
-
using Puppeteer::
|
2
|
+
using Puppeteer::DefineAsyncMethod
|
3
3
|
|
4
4
|
# @param {!Puppeteer.CDPSession} client
|
5
5
|
def initialize(client)
|
@@ -38,9 +38,5 @@ class Puppeteer::EmulationManager
|
|
38
38
|
reload_needed
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
# @return [Future<true|false>]
|
43
|
-
async def async_emulate_viewport(viewport)
|
44
|
-
emulate_viewport(viewport)
|
45
|
-
end
|
41
|
+
define_async_method :async_emulate_viewport
|
46
42
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Puppeteer::Env
|
2
|
+
# indicates whether DEBUG=1 is specified.
|
3
|
+
#
|
4
|
+
# @return [Boolean]
|
5
|
+
def debug?
|
6
|
+
['1', 'true'].include?(ENV['DEBUG'].to_s)
|
7
|
+
end
|
8
|
+
|
9
|
+
def ci?
|
10
|
+
['1', 'true'].include?(ENV['CI'].to_s)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Puppeteer
|
15
|
+
def self.env
|
16
|
+
Puppeteer::Env.new
|
17
|
+
end
|
18
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Puppeteer::ExecutionContext
|
2
2
|
include Puppeteer::IfPresent
|
3
|
-
using Puppeteer::
|
3
|
+
using Puppeteer::DefineAsyncMethod
|
4
4
|
|
5
5
|
EVALUATION_SCRIPT_URL = '__puppeteer_evaluation_script__'
|
6
6
|
SOURCE_URL_REGEX = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m
|
@@ -16,11 +16,6 @@ class Puppeteer::ExecutionContext
|
|
16
16
|
|
17
17
|
attr_reader :client, :world
|
18
18
|
|
19
|
-
# only used in DomWorld#delete_context
|
20
|
-
def _context_id
|
21
|
-
@context_id
|
22
|
-
end
|
23
|
-
|
24
19
|
# @return [Puppeteer::Frame]
|
25
20
|
def frame
|
26
21
|
if_present(@world) do |world|
|
data/lib/puppeteer/frame.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Puppeteer::Frame
|
2
|
-
using Puppeteer::
|
2
|
+
using Puppeteer::DefineAsyncMethod
|
3
3
|
|
4
4
|
# @param {!FrameManager} frameManager
|
5
5
|
# @param {!Puppeteer.CDPSession} client
|
@@ -39,12 +39,7 @@ class Puppeteer::Frame
|
|
39
39
|
@frame_manager.wait_for_frame_navigation(self, timeout: timeout, wait_until: wait_until)
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
# @param wait_until [string|nil] 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2'
|
44
|
-
# @return [Future]
|
45
|
-
async def async_wait_for_navigation(timeout: nil, wait_until: nil)
|
46
|
-
wait_for_navigation(timeout: timeout, wait_until: wait_until)
|
47
|
-
end
|
42
|
+
define_async_method :async_wait_for_navigation
|
48
43
|
|
49
44
|
def execution_context
|
50
45
|
@main_world.execution_context
|
@@ -56,12 +51,16 @@ class Puppeteer::Frame
|
|
56
51
|
@main_world.evaluate_handle(page_function, *args)
|
57
52
|
end
|
58
53
|
|
54
|
+
define_async_method :async_evaluate_handle
|
55
|
+
|
59
56
|
# @param {Function|string} pageFunction
|
60
57
|
# @param {!Array<*>} args
|
61
58
|
def evaluate(page_function, *args)
|
62
59
|
@main_world.evaluate(page_function, *args)
|
63
60
|
end
|
64
61
|
|
62
|
+
define_async_method :async_evaluate
|
63
|
+
|
65
64
|
# `$()` in JavaScript. $ is not allowed to use as a method name in Ruby.
|
66
65
|
# @param {string} selector
|
67
66
|
# @return {!Promise<?Puppeteer.ElementHandle>}
|
@@ -69,6 +68,7 @@ class Puppeteer::Frame
|
|
69
68
|
@main_world.S(selector)
|
70
69
|
end
|
71
70
|
|
71
|
+
define_async_method :async_S
|
72
72
|
|
73
73
|
# `$x()` in JavaScript. $ is not allowed to use as a method name in Ruby.
|
74
74
|
# @param {string} expression
|
@@ -77,6 +77,7 @@ class Puppeteer::Frame
|
|
77
77
|
@main_world.Sx(expression)
|
78
78
|
end
|
79
79
|
|
80
|
+
define_async_method :async_Sx
|
80
81
|
|
81
82
|
# `$eval()` in JavaScript. $ is not allowed to use as a method name in Ruby.
|
82
83
|
# @param {string} selector
|
@@ -87,6 +88,8 @@ class Puppeteer::Frame
|
|
87
88
|
@main_world.Seval(selector, page_function, *args)
|
88
89
|
end
|
89
90
|
|
91
|
+
define_async_method :async_Seval
|
92
|
+
|
90
93
|
# `$$eval()` in JavaScript. $ is not allowed to use as a method name in Ruby.
|
91
94
|
# @param {string} selector
|
92
95
|
# @param {Function|string} pageFunction
|
@@ -96,6 +99,8 @@ class Puppeteer::Frame
|
|
96
99
|
@main_world.SSeval(selector, page_function, *args)
|
97
100
|
end
|
98
101
|
|
102
|
+
define_async_method :async_SSeval
|
103
|
+
|
99
104
|
# `$$()` in JavaScript. $ is not allowed to use as a method name in Ruby.
|
100
105
|
# @param {string} selector
|
101
106
|
# @return {!Promise<!Array<!Puppeteer.ElementHandle>>}
|
@@ -103,12 +108,16 @@ class Puppeteer::Frame
|
|
103
108
|
@main_world.SS(selector)
|
104
109
|
end
|
105
110
|
|
111
|
+
define_async_method :async_SS
|
112
|
+
|
113
|
+
# @return [String]
|
106
114
|
def content
|
107
115
|
@secondary_world.content
|
108
116
|
end
|
109
117
|
|
110
|
-
# @param
|
111
|
-
# @param
|
118
|
+
# @param html [String]
|
119
|
+
# @param timeout [Integer]
|
120
|
+
# @param wait_until [String|Array<String>]
|
112
121
|
def set_content(html, timeout: nil, wait_until: nil)
|
113
122
|
@secondary_world.set_content(html, timeout: timeout, wait_until: wait_until)
|
114
123
|
end
|
@@ -133,7 +142,7 @@ class Puppeteer::Frame
|
|
133
142
|
end
|
134
143
|
|
135
144
|
def child_frames
|
136
|
-
@child_frames.
|
145
|
+
@child_frames.to_a
|
137
146
|
end
|
138
147
|
|
139
148
|
def detached?
|
@@ -152,15 +161,6 @@ class Puppeteer::Frame
|
|
152
161
|
@main_world.add_style_tag(style_tag)
|
153
162
|
end
|
154
163
|
|
155
|
-
# @param selector [String]
|
156
|
-
# @param delay [Number]
|
157
|
-
# @param button [String] "left"|"right"|"middle"
|
158
|
-
# @param click_count [Number]
|
159
|
-
# @return [Future]
|
160
|
-
async def async_click(selector, delay: nil, button: nil, click_count: nil)
|
161
|
-
click(selector, delay: delay, button: button, click_count: click_count)
|
162
|
-
end
|
163
|
-
|
164
164
|
# @param selector [String]
|
165
165
|
# @param delay [Number]
|
166
166
|
# @param button [String] "left"|"right"|"middle"
|
@@ -169,11 +169,15 @@ class Puppeteer::Frame
|
|
169
169
|
@secondary_world.click(selector, delay: delay, button: button, click_count: click_count)
|
170
170
|
end
|
171
171
|
|
172
|
+
define_async_method :async_click
|
173
|
+
|
172
174
|
# @param {string} selector
|
173
175
|
def focus(selector)
|
174
176
|
@secondary_world.focus(selector)
|
175
177
|
end
|
176
178
|
|
179
|
+
define_async_method :async_focus
|
180
|
+
|
177
181
|
# @param {string} selector
|
178
182
|
def hover(selector)
|
179
183
|
@secondary_world.hover(selector)
|
@@ -186,11 +190,15 @@ class Puppeteer::Frame
|
|
186
190
|
@secondary_world.select(selector, *values)
|
187
191
|
end
|
188
192
|
|
193
|
+
define_async_method :async_select
|
194
|
+
|
189
195
|
# @param {string} selector
|
190
196
|
def tap(selector)
|
191
197
|
@secondary_world.tap(selector)
|
192
198
|
end
|
193
199
|
|
200
|
+
define_async_method :async_tap
|
201
|
+
|
194
202
|
# @param selector [String]
|
195
203
|
# @param text [String]
|
196
204
|
# @param delay [Number]
|
@@ -198,27 +206,7 @@ class Puppeteer::Frame
|
|
198
206
|
@main_world.type_text(selector, text, delay: delay)
|
199
207
|
end
|
200
208
|
|
201
|
-
|
202
|
-
# * @param {(string|number|Function)} selectorOrFunctionOrTimeout
|
203
|
-
# * @param {!Object=} options
|
204
|
-
# * @param {!Array<*>} args
|
205
|
-
# * @return {!Promise<?Puppeteer.JSHandle>}
|
206
|
-
# */
|
207
|
-
# waitFor(selectorOrFunctionOrTimeout, options = {}, ...args) {
|
208
|
-
# const xPathPattern = '//';
|
209
|
-
|
210
|
-
# if (helper.isString(selectorOrFunctionOrTimeout)) {
|
211
|
-
# const string = /** @type {string} */ (selectorOrFunctionOrTimeout);
|
212
|
-
# if (string.startsWith(xPathPattern))
|
213
|
-
# return this.waitForXPath(string, options);
|
214
|
-
# return this.waitForSelector(string, options);
|
215
|
-
# }
|
216
|
-
# if (helper.isNumber(selectorOrFunctionOrTimeout))
|
217
|
-
# return new Promise(fulfill => setTimeout(fulfill, /** @type {number} */ (selectorOrFunctionOrTimeout)));
|
218
|
-
# if (typeof selectorOrFunctionOrTimeout === 'function')
|
219
|
-
# return this.waitForFunction(selectorOrFunctionOrTimeout, options, ...args);
|
220
|
-
# return Promise.reject(new Error('Unsupported target type: ' + (typeof selectorOrFunctionOrTimeout)));
|
221
|
-
# }
|
209
|
+
define_async_method :async_type_text
|
222
210
|
|
223
211
|
# @param selector [String]
|
224
212
|
# @param visible [Boolean] Wait for element visible (not 'display: none' nor 'visibility: hidden') on true. default to false.
|
@@ -235,6 +223,13 @@ class Puppeteer::Frame
|
|
235
223
|
result
|
236
224
|
end
|
237
225
|
|
226
|
+
define_async_method :async_wait_for_selector
|
227
|
+
|
228
|
+
# @param milliseconds [Integer] the number of milliseconds to wait.
|
229
|
+
def wait_for_timeout(milliseconds)
|
230
|
+
sleep(milliseconds / 1000.0)
|
231
|
+
end
|
232
|
+
|
238
233
|
# @param xpath [String]
|
239
234
|
# @param visible [Boolean] Wait for element visible (not 'display: none' nor 'visibility: hidden') on true. default to false.
|
240
235
|
# @param hidden [Boolean] Wait for element invisible ('display: none' nor 'visibility: hidden') on true. default to false.
|
@@ -250,14 +245,19 @@ class Puppeteer::Frame
|
|
250
245
|
result
|
251
246
|
end
|
252
247
|
|
253
|
-
|
254
|
-
|
255
|
-
# @param
|
256
|
-
# @
|
257
|
-
|
258
|
-
|
248
|
+
define_async_method :async_wait_for_xpath
|
249
|
+
|
250
|
+
# @param page_function [String]
|
251
|
+
# @param args [Integer|Array]
|
252
|
+
# @param polling [String]
|
253
|
+
# @param timeout [Integer]
|
254
|
+
# @return [Puppeteer::JSHandle]
|
255
|
+
def wait_for_function(page_function, args: [], polling: nil, timeout: nil)
|
256
|
+
@main_world.wait_for_function(page_function, args: args, polling: polling, timeout: timeout)
|
259
257
|
end
|
260
258
|
|
259
|
+
define_async_method :async_wait_for_function
|
260
|
+
|
261
261
|
# @return [String]
|
262
262
|
def title
|
263
263
|
@secondary_world.title
|