puppeteer-ruby 0.0.5 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/docs/Puppeteer.html +53 -43
- data/docs/Puppeteer/AsyncAwaitBehavior.html +1 -1
- data/docs/Puppeteer/Browser.html +255 -147
- data/docs/Puppeteer/BrowserContext.html +1 -1
- data/docs/Puppeteer/BrowserFetcher.html +1 -1
- data/docs/Puppeteer/BrowserRunner.html +1 -1
- data/docs/Puppeteer/BrowserRunner/BrowserProcess.html +1 -1
- data/docs/Puppeteer/CDPSession.html +86 -57
- data/docs/Puppeteer/CDPSession/Error.html +1 -1
- data/docs/Puppeteer/ConcurrentRubyUtils.html +1 -1
- data/docs/Puppeteer/Connection.html +65 -61
- data/docs/Puppeteer/Connection/MessageCallback.html +1 -1
- data/docs/Puppeteer/Connection/ProtocolError.html +1 -1
- data/docs/Puppeteer/Connection/RequestDebugPrinter.html +5 -5
- data/docs/Puppeteer/Connection/ResponseDebugPrinter.html +12 -12
- data/docs/Puppeteer/ConsoleMessage.html +1 -1
- data/docs/Puppeteer/ConsoleMessage/Location.html +1 -1
- data/docs/Puppeteer/DOMWorld.html +708 -69
- data/docs/Puppeteer/DOMWorld/DetachedError.html +1 -1
- data/docs/Puppeteer/DOMWorld/DocumentEvaluationError.html +1 -1
- data/docs/Puppeteer/DebugPrint.html +2 -2
- data/docs/Puppeteer/Device.html +1 -1
- data/docs/Puppeteer/Devices.html +1 -1
- data/docs/Puppeteer/ElementHandle.html +1120 -181
- data/docs/Puppeteer/ElementHandle/BoundingBox.html +507 -0
- data/docs/Puppeteer/ElementHandle/BoxModel.html +404 -0
- data/docs/Puppeteer/ElementHandle/ElementNotFoundError.html +5 -5
- data/docs/Puppeteer/ElementHandle/ElementNotVisibleError.html +5 -5
- data/docs/Puppeteer/ElementHandle/Point.html +40 -29
- data/docs/Puppeteer/ElementHandle/ScrollIntoViewError.html +1 -1
- data/docs/Puppeteer/EmulationManager.html +1 -1
- data/docs/Puppeteer/EventCallbackable.html +1 -1
- data/docs/Puppeteer/EventCallbackable/EventListeners.html +1 -1
- data/docs/Puppeteer/ExecutionContext.html +227 -1
- data/docs/Puppeteer/ExecutionContext/EvaluationError.html +1 -1
- data/docs/Puppeteer/ExecutionContext/JavaScriptExpression.html +1 -1
- data/docs/Puppeteer/ExecutionContext/JavaScriptFunction.html +2 -2
- data/docs/Puppeteer/FileChooser.html +455 -0
- data/docs/Puppeteer/Frame.html +492 -304
- data/docs/Puppeteer/FrameManager.html +22 -26
- data/docs/Puppeteer/FrameManager/NavigationError.html +1 -1
- data/docs/Puppeteer/IfPresent.html +1 -1
- data/docs/Puppeteer/JSHandle.html +1 -1
- data/docs/Puppeteer/Keyboard.html +1 -1
- data/docs/Puppeteer/Keyboard/KeyDefinition.html +1 -1
- data/docs/Puppeteer/Keyboard/KeyDescription.html +1 -1
- data/docs/Puppeteer/Launcher.html +1 -1
- data/docs/Puppeteer/Launcher/Base.html +1 -1
- data/docs/Puppeteer/Launcher/Base/ExecutablePathNotFound.html +1 -1
- data/docs/Puppeteer/Launcher/BrowserOptions.html +1 -1
- data/docs/Puppeteer/Launcher/Chrome.html +64 -23
- data/docs/Puppeteer/Launcher/Chrome/DefaultArgs.html +1 -1
- data/docs/Puppeteer/Launcher/ChromeArgOptions.html +1 -1
- data/docs/Puppeteer/Launcher/LaunchOptions.html +1 -1
- data/docs/Puppeteer/LifecycleWatcher.html +1 -1
- data/docs/Puppeteer/LifecycleWatcher/ExpectedLifecycle.html +1 -1
- data/docs/Puppeteer/LifecycleWatcher/FrameDetachedError.html +1 -1
- data/docs/Puppeteer/LifecycleWatcher/TerminatedError.html +1 -1
- data/docs/Puppeteer/Mouse.html +31 -41
- data/docs/Puppeteer/Mouse/Button.html +1 -1
- data/docs/Puppeteer/NetworkManager.html +1 -1
- data/docs/Puppeteer/NetworkManager/Credentials.html +1 -1
- data/docs/Puppeteer/Page.html +980 -436
- data/docs/Puppeteer/Page/FileChooserTimeoutError.html +206 -0
- data/docs/Puppeteer/Page/ScreenshotOptions.html +1 -1
- data/docs/Puppeteer/Page/ScriptTag.html +24 -24
- data/docs/Puppeteer/Page/StyleTag.html +19 -19
- data/docs/Puppeteer/Page/TargetCrashedError.html +1 -1
- data/docs/Puppeteer/RemoteObject.html +173 -37
- data/docs/Puppeteer/Target.html +149 -197
- data/docs/Puppeteer/Target/InitializeFailure.html +1 -1
- data/docs/Puppeteer/Target/TargetInfo.html +1 -1
- data/docs/Puppeteer/TimeoutError.html +2 -2
- data/docs/Puppeteer/TimeoutSettings.html +1 -1
- data/docs/Puppeteer/TouchScreen.html +1 -1
- data/docs/Puppeteer/Viewport.html +81 -1
- data/docs/Puppeteer/WaitTask.html +434 -8
- data/docs/Puppeteer/WaitTask/TerminatedError.html +1 -1
- data/docs/Puppeteer/WaitTask/TimeoutError.html +206 -0
- data/docs/Puppeteer/WebSocket.html +26 -26
- data/docs/Puppeteer/WebSocket/DriverImpl.html +1 -1
- data/docs/Puppeteer/WebSocket/TransportError.html +124 -0
- data/docs/Puppeteer/WebSocketTransport.html +2 -2
- data/docs/Puppeteer/WebSocktTransportError.html +1 -1
- data/docs/_index.html +47 -19
- data/docs/class_list.html +1 -1
- data/docs/file.README.html +5 -3
- data/docs/index.html +5 -3
- data/docs/method_list.html +788 -444
- data/docs/top-level-namespace.html +1 -1
- data/lib/puppeteer.rb +7 -1
- data/lib/puppeteer/browser.rb +21 -6
- data/lib/puppeteer/browser_runner.rb +1 -1
- data/lib/puppeteer/cdp_session.rb +33 -11
- data/lib/puppeteer/connection.rb +13 -1
- data/lib/puppeteer/dom_world.rb +113 -108
- data/lib/puppeteer/element_handle.rb +183 -222
- data/lib/puppeteer/element_handle/bounding_box.rb +12 -0
- data/lib/puppeteer/element_handle/box_model.rb +19 -0
- data/lib/puppeteer/element_handle/point.rb +26 -0
- data/lib/puppeteer/errors.rb +1 -3
- data/lib/puppeteer/execution_context.rb +36 -17
- data/lib/puppeteer/file_chooser.rb +29 -0
- data/lib/puppeteer/frame.rb +32 -12
- data/lib/puppeteer/frame_manager.rb +0 -2
- data/lib/puppeteer/launcher/chrome.rb +48 -2
- data/lib/puppeteer/mouse.rb +3 -8
- data/lib/puppeteer/page.rb +116 -65
- data/lib/puppeteer/remote_object.rb +15 -1
- data/lib/puppeteer/target.rb +24 -24
- data/lib/puppeteer/version.rb +1 -1
- data/lib/puppeteer/viewport.rb +18 -0
- data/lib/puppeteer/wait_task.rb +183 -1
- data/lib/puppeteer/web_socket.rb +3 -1
- data/lib/puppeteer/web_socket_transport.rb +1 -1
- metadata +12 -2
@@ -114,7 +114,7 @@
|
|
114
114
|
</div>
|
115
115
|
|
116
116
|
<div id="footer">
|
117
|
-
Generated on
|
117
|
+
Generated on Sat Jun 20 17:15:07 2020 by
|
118
118
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
119
119
|
0.9.24 (ruby-2.6.3).
|
120
120
|
</div>
|
@@ -114,7 +114,7 @@
|
|
114
114
|
</div>
|
115
115
|
|
116
116
|
<div id="footer">
|
117
|
-
Generated on
|
117
|
+
Generated on Fri Jun 12 12:38:34 2020 by
|
118
118
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
119
119
|
0.9.24 (ruby-2.6.3).
|
120
120
|
</div>
|
@@ -76,7 +76,7 @@
|
|
76
76
|
|
77
77
|
<dl>
|
78
78
|
<dt>Included in:</dt>
|
79
|
-
<dd><span class='object_link'><a href="Browser.html" title="Puppeteer::Browser (class)">Browser</a></span>, <span class='object_link'><a href="Connection.html" title="Puppeteer::Connection (class)">Connection</a></span>, <span class='object_link'><a href="Connection/RequestDebugPrinter.html" title="Puppeteer::Connection::RequestDebugPrinter (class)">Connection::RequestDebugPrinter</a></span>, <span class='object_link'><a href="Connection/ResponseDebugPrinter.html" title="Puppeteer::Connection::ResponseDebugPrinter (class)">Connection::ResponseDebugPrinter</a></span>, <span class='object_link'><a href="FrameManager.html" title="Puppeteer::FrameManager (class)">FrameManager</a></span>, <span class='object_link'><a href="RemoteObject.html" title="Puppeteer::RemoteObject (class)">RemoteObject</a></span></dd>
|
79
|
+
<dd><span class='object_link'><a href="Browser.html" title="Puppeteer::Browser (class)">Browser</a></span>, <span class='object_link'><a href="CDPSession.html" title="Puppeteer::CDPSession (class)">CDPSession</a></span>, <span class='object_link'><a href="Connection.html" title="Puppeteer::Connection (class)">Connection</a></span>, <span class='object_link'><a href="Connection/RequestDebugPrinter.html" title="Puppeteer::Connection::RequestDebugPrinter (class)">Connection::RequestDebugPrinter</a></span>, <span class='object_link'><a href="Connection/ResponseDebugPrinter.html" title="Puppeteer::Connection::ResponseDebugPrinter (class)">Connection::ResponseDebugPrinter</a></span>, <span class='object_link'><a href="FrameManager.html" title="Puppeteer::FrameManager (class)">FrameManager</a></span>, <span class='object_link'><a href="RemoteObject.html" title="Puppeteer::RemoteObject (class)">RemoteObject</a></span></dd>
|
80
80
|
</dl>
|
81
81
|
|
82
82
|
|
@@ -223,7 +223,7 @@
|
|
223
223
|
</div>
|
224
224
|
|
225
225
|
<div id="footer">
|
226
|
-
Generated on
|
226
|
+
Generated on Sat Jun 20 17:15:05 2020 by
|
227
227
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
228
228
|
0.9.24 (ruby-2.6.3).
|
229
229
|
</div>
|
data/docs/Puppeteer/Device.html
CHANGED
@@ -460,7 +460,7 @@
|
|
460
460
|
</div>
|
461
461
|
|
462
462
|
<div id="footer">
|
463
|
-
Generated on
|
463
|
+
Generated on Sat Jun 20 17:15:06 2020 by
|
464
464
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
465
465
|
0.9.24 (ruby-2.6.3).
|
466
466
|
</div>
|
data/docs/Puppeteer/Devices.html
CHANGED
@@ -129,7 +129,7 @@
|
|
129
129
|
</div>
|
130
130
|
|
131
131
|
<div id="footer">
|
132
|
-
Generated on
|
132
|
+
Generated on Sat Jun 20 17:15:06 2020 by
|
133
133
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
134
134
|
0.9.24 (ruby-2.6.3).
|
135
135
|
</div>
|
@@ -101,7 +101,9 @@
|
|
101
101
|
|
102
102
|
<dl>
|
103
103
|
<dt>Defined in:</dt>
|
104
|
-
<dd>lib/puppeteer/element_handle.rb
|
104
|
+
<dd>lib/puppeteer/element_handle.rb<span class="defines">,<br />
|
105
|
+
lib/puppeteer/element_handle/point.rb,<br /> lib/puppeteer/element_handle/box_model.rb,<br /> lib/puppeteer/element_handle/bounding_box.rb</span>
|
106
|
+
</dd>
|
105
107
|
</dl>
|
106
108
|
|
107
109
|
</div>
|
@@ -112,7 +114,7 @@
|
|
112
114
|
|
113
115
|
|
114
116
|
|
115
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="ElementHandle/ElementNotFoundError.html" title="Puppeteer::ElementHandle::ElementNotFoundError (class)">ElementNotFoundError</a></span>, <span class='object_link'><a href="ElementHandle/ElementNotVisibleError.html" title="Puppeteer::ElementHandle::ElementNotVisibleError (class)">ElementNotVisibleError</a></span>, <span class='object_link'><a href="ElementHandle/Point.html" title="Puppeteer::ElementHandle::Point (class)">Point</a></span>, <span class='object_link'><a href="ElementHandle/ScrollIntoViewError.html" title="Puppeteer::ElementHandle::ScrollIntoViewError (class)">ScrollIntoViewError</a></span>
|
117
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="ElementHandle/BoundingBox.html" title="Puppeteer::ElementHandle::BoundingBox (class)">BoundingBox</a></span>, <span class='object_link'><a href="ElementHandle/BoxModel.html" title="Puppeteer::ElementHandle::BoxModel (class)">BoxModel</a></span>, <span class='object_link'><a href="ElementHandle/ElementNotFoundError.html" title="Puppeteer::ElementHandle::ElementNotFoundError (class)">ElementNotFoundError</a></span>, <span class='object_link'><a href="ElementHandle/ElementNotVisibleError.html" title="Puppeteer::ElementHandle::ElementNotVisibleError (class)">ElementNotVisibleError</a></span>, <span class='object_link'><a href="ElementHandle/Point.html" title="Puppeteer::ElementHandle::Point (class)">Point</a></span>, <span class='object_link'><a href="ElementHandle/ScrollIntoViewError.html" title="Puppeteer::ElementHandle::ScrollIntoViewError (class)">ScrollIntoViewError</a></span>
|
116
118
|
|
117
119
|
|
118
120
|
</p>
|
@@ -177,6 +179,54 @@
|
|
177
179
|
|
178
180
|
<span class="summary_desc"><div class='inline'></div></span>
|
179
181
|
|
182
|
+
</li>
|
183
|
+
|
184
|
+
|
185
|
+
<li class="public ">
|
186
|
+
<span class="summary_signature">
|
187
|
+
|
188
|
+
<a href="#async_Seval-instance_method" title="#async_Seval (instance method)">#<strong>async_Seval</strong> ⇒ Object </a>
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
</span>
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
<span class="summary_desc"><div class='inline'>
|
203
|
+
<p>`$eval()` in JavaScript.</p>
|
204
|
+
</div></span>
|
205
|
+
|
206
|
+
</li>
|
207
|
+
|
208
|
+
|
209
|
+
<li class="public ">
|
210
|
+
<span class="summary_signature">
|
211
|
+
|
212
|
+
<a href="#async_SSeval-instance_method" title="#async_SSeval (instance method)">#<strong>async_SSeval</strong> ⇒ Object </a>
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
</span>
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
<span class="summary_desc"><div class='inline'>
|
227
|
+
<p>`$$eval()` in JavaScript.</p>
|
228
|
+
</div></span>
|
229
|
+
|
180
230
|
</li>
|
181
231
|
|
182
232
|
|
@@ -197,6 +247,50 @@
|
|
197
247
|
|
198
248
|
|
199
249
|
|
250
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
251
|
+
|
252
|
+
</li>
|
253
|
+
|
254
|
+
|
255
|
+
<li class="public ">
|
256
|
+
<span class="summary_signature">
|
257
|
+
|
258
|
+
<a href="#bounding_box-instance_method" title="#bounding_box (instance method)">#<strong>bounding_box</strong> ⇒ BoundingBox|nil </a>
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
</span>
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
273
|
+
|
274
|
+
</li>
|
275
|
+
|
276
|
+
|
277
|
+
<li class="public ">
|
278
|
+
<span class="summary_signature">
|
279
|
+
|
280
|
+
<a href="#box_model-instance_method" title="#box_model (instance method)">#<strong>box_model</strong> ⇒ BoxModel|nil </a>
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
</span>
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
200
294
|
<span class="summary_desc"><div class='inline'></div></span>
|
201
295
|
|
202
296
|
</li>
|
@@ -359,6 +453,28 @@
|
|
359
453
|
<p>`$()` in JavaScript.</p>
|
360
454
|
</div></span>
|
361
455
|
|
456
|
+
</li>
|
457
|
+
|
458
|
+
|
459
|
+
<li class="public ">
|
460
|
+
<span class="summary_signature">
|
461
|
+
|
462
|
+
<a href="#screenshot-instance_method" title="#screenshot (instance method)">#<strong>screenshot</strong>(options = {}) ⇒ Object </a>
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
</span>
|
467
|
+
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
|
476
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
477
|
+
|
362
478
|
</li>
|
363
479
|
|
364
480
|
|
@@ -379,6 +495,28 @@
|
|
379
495
|
|
380
496
|
|
381
497
|
|
498
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
499
|
+
|
500
|
+
</li>
|
501
|
+
|
502
|
+
|
503
|
+
<li class="public ">
|
504
|
+
<span class="summary_signature">
|
505
|
+
|
506
|
+
<a href="#select-instance_method" title="#select (instance method)">#<strong>select</strong>(*values) ⇒ Array<String> </a>
|
507
|
+
|
508
|
+
|
509
|
+
|
510
|
+
</span>
|
511
|
+
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
382
520
|
<span class="summary_desc"><div class='inline'></div></span>
|
383
521
|
|
384
522
|
</li>
|
@@ -453,6 +591,52 @@
|
|
453
591
|
<p>`$$eval()` in JavaScript.</p>
|
454
592
|
</div></span>
|
455
593
|
|
594
|
+
</li>
|
595
|
+
|
596
|
+
|
597
|
+
<li class="public ">
|
598
|
+
<span class="summary_signature">
|
599
|
+
|
600
|
+
<a href="#Sx-instance_method" title="#Sx (instance method)">#<strong>Sx</strong>(expression) ⇒ Array<ElementHandle> </a>
|
601
|
+
|
602
|
+
|
603
|
+
|
604
|
+
</span>
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
|
612
|
+
|
613
|
+
|
614
|
+
<span class="summary_desc"><div class='inline'>
|
615
|
+
<p>`$x()` in JavaScript.</p>
|
616
|
+
</div></span>
|
617
|
+
|
618
|
+
</li>
|
619
|
+
|
620
|
+
|
621
|
+
<li class="public ">
|
622
|
+
<span class="summary_signature">
|
623
|
+
|
624
|
+
<a href="#tap-instance_method" title="#tap (instance method)">#<strong>tap</strong>(&block) ⇒ Object </a>
|
625
|
+
|
626
|
+
|
627
|
+
|
628
|
+
</span>
|
629
|
+
|
630
|
+
|
631
|
+
|
632
|
+
|
633
|
+
|
634
|
+
|
635
|
+
|
636
|
+
|
637
|
+
|
638
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
639
|
+
|
456
640
|
</li>
|
457
641
|
|
458
642
|
|
@@ -473,6 +657,28 @@
|
|
473
657
|
|
474
658
|
|
475
659
|
|
660
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
661
|
+
|
662
|
+
</li>
|
663
|
+
|
664
|
+
|
665
|
+
<li class="public ">
|
666
|
+
<span class="summary_signature">
|
667
|
+
|
668
|
+
<a href="#upload_file-instance_method" title="#upload_file (instance method)">#<strong>upload_file</strong>(*file_paths) ⇒ Object </a>
|
669
|
+
|
670
|
+
|
671
|
+
|
672
|
+
</span>
|
673
|
+
|
674
|
+
|
675
|
+
|
676
|
+
|
677
|
+
|
678
|
+
|
679
|
+
|
680
|
+
|
681
|
+
|
476
682
|
<span class="summary_desc"><div class='inline'></div></span>
|
477
683
|
|
478
684
|
</li>
|
@@ -591,15 +797,15 @@
|
|
591
797
|
<pre class="lines">
|
592
798
|
|
593
799
|
|
594
|
-
10
|
595
|
-
11
|
596
|
-
12
|
597
|
-
13
|
598
800
|
14
|
599
|
-
15
|
801
|
+
15
|
802
|
+
16
|
803
|
+
17
|
804
|
+
18
|
805
|
+
19</pre>
|
600
806
|
</td>
|
601
807
|
<td>
|
602
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
808
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 14</span>
|
603
809
|
|
604
810
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>context:</span><span class='comma'>,</span> <span class='label'>client:</span><span class='comma'>,</span> <span class='label'>remote_object:</span><span class='comma'>,</span> <span class='label'>page:</span><span class='comma'>,</span> <span class='label'>frame_manager:</span><span class='rparen'>)</span>
|
605
811
|
<span class='kw'>super</span><span class='lparen'>(</span><span class='label'>context:</span> <span class='id identifier rubyid_context'>context</span><span class='comma'>,</span> <span class='label'>client:</span> <span class='id identifier rubyid_client'>client</span><span class='comma'>,</span> <span class='label'>remote_object:</span> <span class='id identifier rubyid_remote_object'>remote_object</span><span class='rparen'>)</span>
|
@@ -634,12 +840,12 @@
|
|
634
840
|
<pre class="lines">
|
635
841
|
|
636
842
|
|
637
|
-
|
638
|
-
|
639
|
-
|
843
|
+
21
|
844
|
+
22
|
845
|
+
23</pre>
|
640
846
|
</td>
|
641
847
|
<td>
|
642
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
848
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 21</span>
|
643
849
|
|
644
850
|
<span class='kw'>def</span> <span class='id identifier rubyid_as_element'>as_element</span>
|
645
851
|
<span class='kw'>self</span>
|
@@ -712,12 +918,12 @@
|
|
712
918
|
<pre class="lines">
|
713
919
|
|
714
920
|
|
715
|
-
|
716
|
-
|
717
|
-
|
921
|
+
234
|
922
|
+
235
|
923
|
+
236</pre>
|
718
924
|
</td>
|
719
925
|
<td>
|
720
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
926
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 234</span>
|
721
927
|
|
722
928
|
<span class='id identifier rubyid_async'>async</span> <span class='kw'>def</span> <span class='id identifier rubyid_async_press'>async_press</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='label'>delay:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
723
929
|
<span class='id identifier rubyid_press'>press</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='label'>delay:</span> <span class='id identifier rubyid_delay'>delay</span><span class='rparen'>)</span>
|
@@ -728,9 +934,9 @@
|
|
728
934
|
</div>
|
729
935
|
|
730
936
|
<div class="method_details ">
|
731
|
-
<h3 class="signature " id="
|
937
|
+
<h3 class="signature " id="async_Seval-instance_method">
|
732
938
|
|
733
|
-
#<strong>
|
939
|
+
#<strong>async_Seval</strong> ⇒ <tt>Object</tt>
|
734
940
|
|
735
941
|
|
736
942
|
|
@@ -739,6 +945,8 @@
|
|
739
945
|
</h3><div class="docstring">
|
740
946
|
<div class="discussion">
|
741
947
|
|
948
|
+
<p>`$eval()` in JavaScript. $ is not allowed to use as a method name in Ruby.</p>
|
949
|
+
|
742
950
|
|
743
951
|
</div>
|
744
952
|
</div>
|
@@ -748,7 +956,7 @@
|
|
748
956
|
|
749
957
|
<li>
|
750
958
|
|
751
|
-
<span class='name'>
|
959
|
+
<span class='name'>selector</span>
|
752
960
|
|
753
961
|
|
754
962
|
<span class='type'>(<tt>String</tt>)</span>
|
@@ -759,10 +967,10 @@
|
|
759
967
|
|
760
968
|
<li>
|
761
969
|
|
762
|
-
<span class='name'>
|
970
|
+
<span class='name'>page_function</span>
|
763
971
|
|
764
972
|
|
765
|
-
<span class='type'>(<tt>
|
973
|
+
<span class='type'>(<tt>String</tt>)</span>
|
766
974
|
|
767
975
|
|
768
976
|
|
@@ -776,7 +984,7 @@
|
|
776
984
|
<li>
|
777
985
|
|
778
986
|
|
779
|
-
<span class='type'>(<tt>
|
987
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
780
988
|
|
781
989
|
|
782
990
|
|
@@ -790,15 +998,15 @@
|
|
790
998
|
<pre class="lines">
|
791
999
|
|
792
1000
|
|
793
|
-
|
794
|
-
|
795
|
-
|
1001
|
+
363
|
1002
|
+
364
|
1003
|
+
365</pre>
|
796
1004
|
</td>
|
797
1005
|
<td>
|
798
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
1006
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 363</span>
|
799
1007
|
|
800
|
-
<span class='id identifier rubyid_async'>async</span> <span class='kw'>def</span> <span class='id identifier
|
801
|
-
<span class='
|
1008
|
+
<span class='id identifier rubyid_async'>async</span> <span class='kw'>def</span> <span class='id identifier rubyid_async_Seval'>async_Seval</span><span class='lparen'>(</span><span class='id identifier rubyid_selector'>selector</span><span class='comma'>,</span> <span class='id identifier rubyid_page_function'>page_function</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
1009
|
+
<span class='const'><span class='object_link'><a href="#Seval-instance_method" title="Puppeteer::ElementHandle#Seval (method)">Seval</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_selector'>selector</span><span class='comma'>,</span> <span class='id identifier rubyid_page_function'>page_function</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
802
1010
|
<span class='kw'>end</span></pre>
|
803
1011
|
</td>
|
804
1012
|
</tr>
|
@@ -806,9 +1014,9 @@
|
|
806
1014
|
</div>
|
807
1015
|
|
808
1016
|
<div class="method_details ">
|
809
|
-
<h3 class="signature " id="
|
1017
|
+
<h3 class="signature " id="async_SSeval-instance_method">
|
810
1018
|
|
811
|
-
#<strong>
|
1019
|
+
#<strong>async_SSeval</strong> ⇒ <tt>Object</tt>
|
812
1020
|
|
813
1021
|
|
814
1022
|
|
@@ -817,6 +1025,8 @@
|
|
817
1025
|
</h3><div class="docstring">
|
818
1026
|
<div class="discussion">
|
819
1027
|
|
1028
|
+
<p>`$$eval()` in JavaScript. $ is not allowed to use as a method name in Ruby.</p>
|
1029
|
+
|
820
1030
|
|
821
1031
|
</div>
|
822
1032
|
</div>
|
@@ -826,65 +1036,351 @@
|
|
826
1036
|
|
827
1037
|
<li>
|
828
1038
|
|
829
|
-
<span class='name'>
|
830
|
-
|
1039
|
+
<span class='name'>selector</span>
|
831
1040
|
|
832
|
-
<span class='type'>(<tt>Number</tt>)</span>
|
833
1041
|
|
1042
|
+
<span class='type'>(<tt>String</tt>)</span>
|
834
1043
|
|
835
|
-
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
836
1044
|
|
837
1045
|
|
838
1046
|
</li>
|
839
1047
|
|
840
1048
|
<li>
|
841
1049
|
|
842
|
-
<span class='name'>
|
1050
|
+
<span class='name'>page_function</span>
|
843
1051
|
|
844
1052
|
|
845
1053
|
<span class='type'>(<tt>String</tt>)</span>
|
846
1054
|
|
847
1055
|
|
848
|
-
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
849
|
-
|
850
|
-
|
851
|
-
—
|
852
|
-
<div class='inline'>
|
853
|
-
<p>“left”|“right”|“middle”</p>
|
854
|
-
</div>
|
855
1056
|
|
856
1057
|
</li>
|
857
1058
|
|
1059
|
+
</ul>
|
1060
|
+
|
1061
|
+
<p class="tag_title">Returns:</p>
|
1062
|
+
<ul class="return">
|
1063
|
+
|
858
1064
|
<li>
|
859
1065
|
|
860
|
-
<span class='name'>click_count</span>
|
861
|
-
|
862
|
-
|
863
|
-
<span class='type'>(<tt>Number</tt>)</span>
|
864
1066
|
|
1067
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
865
1068
|
|
866
|
-
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
867
1069
|
|
868
1070
|
|
869
1071
|
</li>
|
870
1072
|
|
871
1073
|
</ul>
|
872
1074
|
|
873
|
-
|
874
1075
|
</div><table class="source_code">
|
875
1076
|
<tr>
|
876
1077
|
<td>
|
877
1078
|
<pre class="lines">
|
878
1079
|
|
879
1080
|
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
157
|
884
|
-
158</pre>
|
1081
|
+
386
|
1082
|
+
387
|
1083
|
+
388</pre>
|
885
1084
|
</td>
|
886
1085
|
<td>
|
887
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
1086
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 386</span>
|
1087
|
+
|
1088
|
+
<span class='id identifier rubyid_async'>async</span> <span class='kw'>def</span> <span class='id identifier rubyid_async_SSeval'>async_SSeval</span><span class='lparen'>(</span><span class='id identifier rubyid_selector'>selector</span><span class='comma'>,</span> <span class='id identifier rubyid_page_function'>page_function</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
1089
|
+
<span class='const'><span class='object_link'><a href="#SSeval-instance_method" title="Puppeteer::ElementHandle#SSeval (method)">SSeval</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_selector'>selector</span><span class='comma'>,</span> <span class='id identifier rubyid_page_function'>page_function</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
1090
|
+
<span class='kw'>end</span></pre>
|
1091
|
+
</td>
|
1092
|
+
</tr>
|
1093
|
+
</table>
|
1094
|
+
</div>
|
1095
|
+
|
1096
|
+
<div class="method_details ">
|
1097
|
+
<h3 class="signature " id="async_type_text-instance_method">
|
1098
|
+
|
1099
|
+
#<strong>async_type_text</strong> ⇒ <tt>Future</tt>
|
1100
|
+
|
1101
|
+
|
1102
|
+
|
1103
|
+
|
1104
|
+
|
1105
|
+
</h3><div class="docstring">
|
1106
|
+
<div class="discussion">
|
1107
|
+
|
1108
|
+
|
1109
|
+
</div>
|
1110
|
+
</div>
|
1111
|
+
<div class="tags">
|
1112
|
+
<p class="tag_title">Parameters:</p>
|
1113
|
+
<ul class="param">
|
1114
|
+
|
1115
|
+
<li>
|
1116
|
+
|
1117
|
+
<span class='name'>text</span>
|
1118
|
+
|
1119
|
+
|
1120
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1121
|
+
|
1122
|
+
|
1123
|
+
|
1124
|
+
</li>
|
1125
|
+
|
1126
|
+
<li>
|
1127
|
+
|
1128
|
+
<span class='name'>delay</span>
|
1129
|
+
|
1130
|
+
|
1131
|
+
<span class='type'>(<tt>number|nil</tt>)</span>
|
1132
|
+
|
1133
|
+
|
1134
|
+
|
1135
|
+
</li>
|
1136
|
+
|
1137
|
+
</ul>
|
1138
|
+
|
1139
|
+
<p class="tag_title">Returns:</p>
|
1140
|
+
<ul class="return">
|
1141
|
+
|
1142
|
+
<li>
|
1143
|
+
|
1144
|
+
|
1145
|
+
<span class='type'>(<tt>Future</tt>)</span>
|
1146
|
+
|
1147
|
+
|
1148
|
+
|
1149
|
+
</li>
|
1150
|
+
|
1151
|
+
</ul>
|
1152
|
+
|
1153
|
+
</div><table class="source_code">
|
1154
|
+
<tr>
|
1155
|
+
<td>
|
1156
|
+
<pre class="lines">
|
1157
|
+
|
1158
|
+
|
1159
|
+
220
|
1160
|
+
221
|
1161
|
+
222</pre>
|
1162
|
+
</td>
|
1163
|
+
<td>
|
1164
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 220</span>
|
1165
|
+
|
1166
|
+
<span class='id identifier rubyid_async'>async</span> <span class='kw'>def</span> <span class='id identifier rubyid_async_type_text'>async_type_text</span><span class='lparen'>(</span><span class='id identifier rubyid_text'>text</span><span class='comma'>,</span> <span class='label'>delay:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
1167
|
+
<span class='id identifier rubyid_type_text'>type_text</span><span class='lparen'>(</span><span class='id identifier rubyid_text'>text</span><span class='comma'>,</span> <span class='label'>delay:</span> <span class='id identifier rubyid_delay'>delay</span><span class='rparen'>)</span>
|
1168
|
+
<span class='kw'>end</span></pre>
|
1169
|
+
</td>
|
1170
|
+
</tr>
|
1171
|
+
</table>
|
1172
|
+
</div>
|
1173
|
+
|
1174
|
+
<div class="method_details ">
|
1175
|
+
<h3 class="signature " id="bounding_box-instance_method">
|
1176
|
+
|
1177
|
+
#<strong>bounding_box</strong> ⇒ <tt><span class='object_link'><a href="ElementHandle/BoundingBox.html" title="Puppeteer::ElementHandle::BoundingBox (class)">BoundingBox</a></span>|nil</tt>
|
1178
|
+
|
1179
|
+
|
1180
|
+
|
1181
|
+
|
1182
|
+
|
1183
|
+
</h3><div class="docstring">
|
1184
|
+
<div class="discussion">
|
1185
|
+
|
1186
|
+
|
1187
|
+
</div>
|
1188
|
+
</div>
|
1189
|
+
<div class="tags">
|
1190
|
+
|
1191
|
+
<p class="tag_title">Returns:</p>
|
1192
|
+
<ul class="return">
|
1193
|
+
|
1194
|
+
<li>
|
1195
|
+
|
1196
|
+
|
1197
|
+
<span class='type'>(<tt><span class='object_link'><a href="ElementHandle/BoundingBox.html" title="Puppeteer::ElementHandle::BoundingBox (class)">BoundingBox</a></span>|nil</tt>)</span>
|
1198
|
+
|
1199
|
+
|
1200
|
+
|
1201
|
+
</li>
|
1202
|
+
|
1203
|
+
</ul>
|
1204
|
+
|
1205
|
+
</div><table class="source_code">
|
1206
|
+
<tr>
|
1207
|
+
<td>
|
1208
|
+
<pre class="lines">
|
1209
|
+
|
1210
|
+
|
1211
|
+
239
|
1212
|
+
240
|
1213
|
+
241
|
1214
|
+
242
|
1215
|
+
243
|
1216
|
+
244
|
1217
|
+
245
|
1218
|
+
246
|
1219
|
+
247
|
1220
|
+
248
|
1221
|
+
249
|
1222
|
+
250
|
1223
|
+
251
|
1224
|
+
252</pre>
|
1225
|
+
</td>
|
1226
|
+
<td>
|
1227
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 239</span>
|
1228
|
+
|
1229
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_bounding_box'>bounding_box</span>
|
1230
|
+
<span class='id identifier rubyid_if_present'>if_present</span><span class='lparen'>(</span><span class='id identifier rubyid_box_model'>box_model</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_result_model'>result_model</span><span class='op'>|</span>
|
1231
|
+
<span class='id identifier rubyid_quads'>quads</span> <span class='op'>=</span> <span class='id identifier rubyid_result_model'>result_model</span><span class='period'>.</span><span class='id identifier rubyid_border'>border</span>
|
1232
|
+
|
1233
|
+
<span class='id identifier rubyid_x'>x</span> <span class='op'>=</span> <span class='id identifier rubyid_quads'>quads</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:x</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span>
|
1234
|
+
<span class='id identifier rubyid_y'>y</span> <span class='op'>=</span> <span class='id identifier rubyid_quads'>quads</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:y</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span>
|
1235
|
+
<span class='const'><span class='object_link'><a href="ElementHandle/BoundingBox.html" title="Puppeteer::ElementHandle::BoundingBox (class)">BoundingBox</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ElementHandle/BoundingBox.html#initialize-instance_method" title="Puppeteer::ElementHandle::BoundingBox#initialize (method)">new</a></span></span><span class='lparen'>(</span>
|
1236
|
+
<span class='label'>x:</span> <span class='id identifier rubyid_x'>x</span><span class='comma'>,</span>
|
1237
|
+
<span class='label'>y:</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span>
|
1238
|
+
<span class='label'>width:</span> <span class='id identifier rubyid_quads'>quads</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:x</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span> <span class='op'>-</span> <span class='id identifier rubyid_x'>x</span><span class='comma'>,</span>
|
1239
|
+
<span class='label'>height:</span> <span class='id identifier rubyid_quads'>quads</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:y</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span> <span class='op'>-</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span>
|
1240
|
+
<span class='rparen'>)</span>
|
1241
|
+
<span class='kw'>end</span>
|
1242
|
+
<span class='kw'>end</span></pre>
|
1243
|
+
</td>
|
1244
|
+
</tr>
|
1245
|
+
</table>
|
1246
|
+
</div>
|
1247
|
+
|
1248
|
+
<div class="method_details ">
|
1249
|
+
<h3 class="signature " id="box_model-instance_method">
|
1250
|
+
|
1251
|
+
#<strong>box_model</strong> ⇒ <tt><span class='object_link'><a href="ElementHandle/BoxModel.html" title="Puppeteer::ElementHandle::BoxModel (class)">BoxModel</a></span>|nil</tt>
|
1252
|
+
|
1253
|
+
|
1254
|
+
|
1255
|
+
|
1256
|
+
|
1257
|
+
</h3><div class="docstring">
|
1258
|
+
<div class="discussion">
|
1259
|
+
|
1260
|
+
|
1261
|
+
</div>
|
1262
|
+
</div>
|
1263
|
+
<div class="tags">
|
1264
|
+
|
1265
|
+
<p class="tag_title">Returns:</p>
|
1266
|
+
<ul class="return">
|
1267
|
+
|
1268
|
+
<li>
|
1269
|
+
|
1270
|
+
|
1271
|
+
<span class='type'>(<tt><span class='object_link'><a href="ElementHandle/BoxModel.html" title="Puppeteer::ElementHandle::BoxModel (class)">BoxModel</a></span>|nil</tt>)</span>
|
1272
|
+
|
1273
|
+
|
1274
|
+
|
1275
|
+
</li>
|
1276
|
+
|
1277
|
+
</ul>
|
1278
|
+
|
1279
|
+
</div><table class="source_code">
|
1280
|
+
<tr>
|
1281
|
+
<td>
|
1282
|
+
<pre class="lines">
|
1283
|
+
|
1284
|
+
|
1285
|
+
255
|
1286
|
+
256
|
1287
|
+
257
|
1288
|
+
258
|
1289
|
+
259</pre>
|
1290
|
+
</td>
|
1291
|
+
<td>
|
1292
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 255</span>
|
1293
|
+
|
1294
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_box_model'>box_model</span>
|
1295
|
+
<span class='id identifier rubyid_if_present'>if_present</span><span class='lparen'>(</span><span class='ivar'>@remote_object</span><span class='period'>.</span><span class='id identifier rubyid_box_model'>box_model</span><span class='lparen'>(</span><span class='ivar'>@client</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_result'>result</span><span class='op'>|</span>
|
1296
|
+
<span class='const'><span class='object_link'><a href="ElementHandle/BoxModel.html" title="Puppeteer::ElementHandle::BoxModel (class)">BoxModel</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ElementHandle/BoxModel.html#initialize-instance_method" title="Puppeteer::ElementHandle::BoxModel#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>model</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
1297
|
+
<span class='kw'>end</span>
|
1298
|
+
<span class='kw'>end</span></pre>
|
1299
|
+
</td>
|
1300
|
+
</tr>
|
1301
|
+
</table>
|
1302
|
+
</div>
|
1303
|
+
|
1304
|
+
<div class="method_details ">
|
1305
|
+
<h3 class="signature " id="click-instance_method">
|
1306
|
+
|
1307
|
+
#<strong>click</strong>(delay: nil, button: nil, click_count: nil) ⇒ <tt>Object</tt>
|
1308
|
+
|
1309
|
+
|
1310
|
+
|
1311
|
+
|
1312
|
+
|
1313
|
+
</h3><div class="docstring">
|
1314
|
+
<div class="discussion">
|
1315
|
+
|
1316
|
+
|
1317
|
+
</div>
|
1318
|
+
</div>
|
1319
|
+
<div class="tags">
|
1320
|
+
<p class="tag_title">Parameters:</p>
|
1321
|
+
<ul class="param">
|
1322
|
+
|
1323
|
+
<li>
|
1324
|
+
|
1325
|
+
<span class='name'>delay</span>
|
1326
|
+
|
1327
|
+
|
1328
|
+
<span class='type'>(<tt>Number</tt>)</span>
|
1329
|
+
|
1330
|
+
|
1331
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
1332
|
+
|
1333
|
+
|
1334
|
+
</li>
|
1335
|
+
|
1336
|
+
<li>
|
1337
|
+
|
1338
|
+
<span class='name'>button</span>
|
1339
|
+
|
1340
|
+
|
1341
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1342
|
+
|
1343
|
+
|
1344
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
1345
|
+
|
1346
|
+
|
1347
|
+
—
|
1348
|
+
<div class='inline'>
|
1349
|
+
<p>“left”|“right”|“middle”</p>
|
1350
|
+
</div>
|
1351
|
+
|
1352
|
+
</li>
|
1353
|
+
|
1354
|
+
<li>
|
1355
|
+
|
1356
|
+
<span class='name'>click_count</span>
|
1357
|
+
|
1358
|
+
|
1359
|
+
<span class='type'>(<tt>Number</tt>)</span>
|
1360
|
+
|
1361
|
+
|
1362
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
1363
|
+
|
1364
|
+
|
1365
|
+
</li>
|
1366
|
+
|
1367
|
+
</ul>
|
1368
|
+
|
1369
|
+
|
1370
|
+
</div><table class="source_code">
|
1371
|
+
<tr>
|
1372
|
+
<td>
|
1373
|
+
<pre class="lines">
|
1374
|
+
|
1375
|
+
|
1376
|
+
117
|
1377
|
+
118
|
1378
|
+
119
|
1379
|
+
120
|
1380
|
+
121</pre>
|
1381
|
+
</td>
|
1382
|
+
<td>
|
1383
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 117</span>
|
888
1384
|
|
889
1385
|
<span class='kw'>def</span> <span class='id identifier rubyid_click'>click</span><span class='lparen'>(</span><span class='label'>delay:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>button:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>click_count:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
890
1386
|
<span class='id identifier rubyid_scroll_into_view_if_needed'>scroll_into_view_if_needed</span>
|
@@ -911,31 +1407,31 @@
|
|
911
1407
|
<pre class="lines">
|
912
1408
|
|
913
1409
|
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
1410
|
+
64
|
1411
|
+
65
|
1412
|
+
66
|
1413
|
+
67
|
1414
|
+
68
|
1415
|
+
69
|
1416
|
+
70
|
1417
|
+
71
|
1418
|
+
72
|
1419
|
+
73
|
1420
|
+
74
|
1421
|
+
75
|
1422
|
+
76
|
1423
|
+
77
|
1424
|
+
78
|
1425
|
+
79
|
1426
|
+
80
|
1427
|
+
81
|
1428
|
+
82
|
1429
|
+
83
|
1430
|
+
84
|
1431
|
+
85</pre>
|
936
1432
|
</td>
|
937
1433
|
<td>
|
938
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
1434
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 64</span>
|
939
1435
|
|
940
1436
|
<span class='kw'>def</span> <span class='id identifier rubyid_clickable_point'>clickable_point</span>
|
941
1437
|
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='ivar'>@remote_object</span><span class='period'>.</span><span class='id identifier rubyid_content_quads'>content_quads</span><span class='lparen'>(</span><span class='ivar'>@client</span><span class='rparen'>)</span>
|
@@ -979,18 +1475,18 @@
|
|
979
1475
|
<pre class="lines">
|
980
1476
|
|
981
1477
|
|
982
|
-
21
|
983
|
-
22
|
984
|
-
23
|
985
|
-
24
|
986
1478
|
25
|
987
1479
|
26
|
988
1480
|
27
|
989
1481
|
28
|
990
|
-
29
|
1482
|
+
29
|
1483
|
+
30
|
1484
|
+
31
|
1485
|
+
32
|
1486
|
+
33</pre>
|
991
1487
|
</td>
|
992
1488
|
<td>
|
993
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
1489
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 25</span>
|
994
1490
|
|
995
1491
|
<span class='kw'>def</span> <span class='id identifier rubyid_content_frame'>content_frame</span>
|
996
1492
|
<span class='id identifier rubyid_node_info'>node_info</span> <span class='op'>=</span> <span class='ivar'>@remote_object</span><span class='period'>.</span><span class='id identifier rubyid_node_info'>node_info</span>
|
@@ -1021,12 +1517,12 @@
|
|
1021
1517
|
<pre class="lines">
|
1022
1518
|
|
1023
1519
|
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1520
|
+
202
|
1521
|
+
203
|
1522
|
+
204</pre>
|
1027
1523
|
</td>
|
1028
1524
|
<td>
|
1029
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
1525
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 202</span>
|
1030
1526
|
|
1031
1527
|
<span class='kw'>def</span> <span class='id identifier rubyid_focus'>focus</span>
|
1032
1528
|
<span class='id identifier rubyid_evaluate'>evaluate</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>element => element.focus()</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
@@ -1088,13 +1584,13 @@
|
|
1088
1584
|
<pre class="lines">
|
1089
1585
|
|
1090
1586
|
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1587
|
+
226
|
1588
|
+
227
|
1589
|
+
228
|
1590
|
+
229</pre>
|
1095
1591
|
</td>
|
1096
1592
|
<td>
|
1097
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
1593
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 226</span>
|
1098
1594
|
|
1099
1595
|
<span class='kw'>def</span> <span class='id identifier rubyid_press'>press</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='label'>delay:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
1100
1596
|
<span class='id identifier rubyid_focus'>focus</span>
|
@@ -1137,44 +1633,164 @@
|
|
1137
1633
|
|
1138
1634
|
</li>
|
1139
1635
|
|
1140
|
-
</ul>
|
1636
|
+
</ul>
|
1637
|
+
|
1638
|
+
|
1639
|
+
</div><table class="source_code">
|
1640
|
+
<tr>
|
1641
|
+
<td>
|
1642
|
+
<pre class="lines">
|
1643
|
+
|
1644
|
+
|
1645
|
+
312
|
1646
|
+
313
|
1647
|
+
314
|
1648
|
+
315
|
1649
|
+
316
|
1650
|
+
317
|
1651
|
+
318
|
1652
|
+
319
|
1653
|
+
320
|
1654
|
+
321
|
1655
|
+
322
|
1656
|
+
323
|
1657
|
+
324</pre>
|
1658
|
+
</td>
|
1659
|
+
<td>
|
1660
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 312</span>
|
1661
|
+
|
1662
|
+
<span class='kw'>def</span> <span class='const'>S</span><span class='lparen'>(</span><span class='id identifier rubyid_selector'>selector</span><span class='rparen'>)</span>
|
1663
|
+
<span class='id identifier rubyid_handle'>handle</span> <span class='op'>=</span> <span class='id identifier rubyid_evaluate_handle'>evaluate_handle</span><span class='lparen'>(</span>
|
1664
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>(element, selector) => element.querySelector(selector)</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
1665
|
+
<span class='id identifier rubyid_selector'>selector</span><span class='comma'>,</span>
|
1666
|
+
<span class='rparen'>)</span>
|
1667
|
+
<span class='id identifier rubyid_element'>element</span> <span class='op'>=</span> <span class='id identifier rubyid_handle'>handle</span><span class='period'>.</span><span class='id identifier rubyid_as_element'>as_element</span>
|
1668
|
+
|
1669
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_element'>element</span>
|
1670
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_element'>element</span>
|
1671
|
+
<span class='kw'>end</span>
|
1672
|
+
<span class='id identifier rubyid_handle'>handle</span><span class='period'>.</span><span class='id identifier rubyid_dispose'>dispose</span>
|
1673
|
+
<span class='kw'>nil</span>
|
1674
|
+
<span class='kw'>end</span></pre>
|
1675
|
+
</td>
|
1676
|
+
</tr>
|
1677
|
+
</table>
|
1678
|
+
</div>
|
1679
|
+
|
1680
|
+
<div class="method_details ">
|
1681
|
+
<h3 class="signature " id="screenshot-instance_method">
|
1682
|
+
|
1683
|
+
#<strong>screenshot</strong>(options = {}) ⇒ <tt>Object</tt>
|
1684
|
+
|
1141
1685
|
|
1686
|
+
|
1142
1687
|
|
1143
|
-
|
1688
|
+
|
1689
|
+
</h3><table class="source_code">
|
1144
1690
|
<tr>
|
1145
1691
|
<td>
|
1146
1692
|
<pre class="lines">
|
1147
1693
|
|
1148
1694
|
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1695
|
+
261
|
1696
|
+
262
|
1697
|
+
263
|
1698
|
+
264
|
1699
|
+
265
|
1700
|
+
266
|
1701
|
+
267
|
1702
|
+
268
|
1703
|
+
269
|
1704
|
+
270
|
1705
|
+
271
|
1706
|
+
272
|
1707
|
+
273
|
1708
|
+
274
|
1709
|
+
275
|
1710
|
+
276
|
1711
|
+
277
|
1712
|
+
278
|
1713
|
+
279
|
1714
|
+
280
|
1715
|
+
281
|
1716
|
+
282
|
1717
|
+
283
|
1718
|
+
284
|
1719
|
+
285
|
1720
|
+
286
|
1721
|
+
287
|
1722
|
+
288
|
1723
|
+
289
|
1724
|
+
290
|
1725
|
+
291
|
1726
|
+
292
|
1727
|
+
293
|
1728
|
+
294
|
1729
|
+
295
|
1730
|
+
296
|
1731
|
+
297
|
1732
|
+
298
|
1733
|
+
299
|
1734
|
+
300
|
1735
|
+
301
|
1736
|
+
302
|
1737
|
+
303
|
1738
|
+
304
|
1739
|
+
305
|
1740
|
+
306
|
1741
|
+
307
|
1742
|
+
308</pre>
|
1162
1743
|
</td>
|
1163
1744
|
<td>
|
1164
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
1745
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 261</span>
|
1165
1746
|
|
1166
|
-
<span class='kw'>def</span> <span class='
|
1167
|
-
<span class='id identifier
|
1168
|
-
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>(element, selector) => element.querySelector(selector)</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
1169
|
-
<span class='id identifier rubyid_selector'>selector</span><span class='comma'>,</span>
|
1170
|
-
<span class='rparen'>)</span>
|
1171
|
-
<span class='id identifier rubyid_element'>element</span> <span class='op'>=</span> <span class='id identifier rubyid_handle'>handle</span><span class='period'>.</span><span class='id identifier rubyid_as_element'>as_element</span>
|
1747
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_screenshot'>screenshot</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
1748
|
+
<span class='id identifier rubyid_needs_viewport_reset'>needs_viewport_reset</span> <span class='op'>=</span> <span class='kw'>false</span>
|
1172
1749
|
|
1173
|
-
<span class='
|
1174
|
-
|
1750
|
+
<span class='id identifier rubyid_box'>box</span> <span class='op'>=</span> <span class='id identifier rubyid_bounding_box'>bounding_box</span>
|
1751
|
+
<span class='kw'>unless</span> <span class='id identifier rubyid_box'>box</span>
|
1752
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="ElementHandle/ElementNotVisibleError.html" title="Puppeteer::ElementHandle::ElementNotVisibleError (class)">ElementNotVisibleError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ElementHandle/ElementNotVisibleError.html#initialize-instance_method" title="Puppeteer::ElementHandle::ElementNotVisibleError#initialize (method)">new</a></span></span>
|
1753
|
+
<span class='kw'>end</span>
|
1754
|
+
|
1755
|
+
<span class='id identifier rubyid_viewport'>viewport</span> <span class='op'>=</span> <span class='ivar'>@page</span><span class='period'>.</span><span class='id identifier rubyid_viewport'>viewport</span>
|
1756
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_viewport'>viewport</span> <span class='op'>&&</span> <span class='lparen'>(</span><span class='id identifier rubyid_box'>box</span><span class='period'>.</span><span class='id identifier rubyid_width'>width</span> <span class='op'>></span> <span class='id identifier rubyid_viewport'>viewport</span><span class='period'>.</span><span class='id identifier rubyid_width'>width</span> <span class='op'>||</span> <span class='id identifier rubyid_box'>box</span><span class='period'>.</span><span class='id identifier rubyid_height'>height</span> <span class='op'>></span> <span class='id identifier rubyid_viewport'>viewport</span><span class='period'>.</span><span class='id identifier rubyid_height'>height</span><span class='rparen'>)</span>
|
1757
|
+
<span class='id identifier rubyid_new_viewport'>new_viewport</span> <span class='op'>=</span> <span class='id identifier rubyid_viewport'>viewport</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span>
|
1758
|
+
<span class='label'>width:</span> <span class='lbracket'>[</span><span class='id identifier rubyid_viewport'>viewport</span><span class='period'>.</span><span class='id identifier rubyid_width'>width</span><span class='comma'>,</span> <span class='id identifier rubyid_box'>box</span><span class='period'>.</span><span class='id identifier rubyid_width'>width</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span><span class='comma'>,</span>
|
1759
|
+
<span class='label'>height:</span> <span class='lbracket'>[</span><span class='id identifier rubyid_viewport'>viewport</span><span class='period'>.</span><span class='id identifier rubyid_height'>height</span><span class='comma'>,</span> <span class='id identifier rubyid_box'>box</span><span class='period'>.</span><span class='id identifier rubyid_height'>height</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span><span class='comma'>,</span>
|
1760
|
+
<span class='rparen'>)</span>
|
1761
|
+
<span class='ivar'>@page</span><span class='period'>.</span><span class='id identifier rubyid_viewport'>viewport</span> <span class='op'>=</span> <span class='id identifier rubyid_new_viewport'>new_viewport</span>
|
1762
|
+
|
1763
|
+
<span class='id identifier rubyid_needs_viewport_reset'>needs_viewport_reset</span> <span class='op'>=</span> <span class='kw'>true</span>
|
1764
|
+
<span class='kw'>end</span>
|
1765
|
+
<span class='id identifier rubyid_scroll_into_view_if_needed'>scroll_into_view_if_needed</span>
|
1766
|
+
|
1767
|
+
<span class='id identifier rubyid_box'>box</span> <span class='op'>=</span> <span class='id identifier rubyid_bounding_box'>bounding_box</span>
|
1768
|
+
<span class='kw'>unless</span> <span class='id identifier rubyid_box'>box</span>
|
1769
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="ElementHandle/ElementNotVisibleError.html" title="Puppeteer::ElementHandle::ElementNotVisibleError (class)">ElementNotVisibleError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ElementHandle/ElementNotVisibleError.html#initialize-instance_method" title="Puppeteer::ElementHandle::ElementNotVisibleError#initialize (method)">new</a></span></span>
|
1770
|
+
<span class='kw'>end</span>
|
1771
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_box'>box</span><span class='period'>.</span><span class='id identifier rubyid_width'>width</span> <span class='op'>==</span> <span class='int'>0</span>
|
1772
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Node has 0 width.</span><span class='tstring_end'>'</span></span>
|
1773
|
+
<span class='kw'>end</span>
|
1774
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_box'>box</span><span class='period'>.</span><span class='id identifier rubyid_height'>height</span> <span class='op'>==</span> <span class='int'>0</span>
|
1775
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Node has 0 height.</span><span class='tstring_end'>'</span></span>
|
1776
|
+
<span class='kw'>end</span>
|
1777
|
+
|
1778
|
+
<span class='id identifier rubyid_layout_metrics'>layout_metrics</span> <span class='op'>=</span> <span class='ivar'>@client</span><span class='period'>.</span><span class='id identifier rubyid_send_message'>send_message</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Page.getLayoutMetrics</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
1779
|
+
<span class='id identifier rubyid_page_x'>page_x</span> <span class='op'>=</span> <span class='id identifier rubyid_layout_metrics'>layout_metrics</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>layoutViewport</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>pageX</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span>
|
1780
|
+
<span class='id identifier rubyid_page_y'>page_y</span> <span class='op'>=</span> <span class='id identifier rubyid_layout_metrics'>layout_metrics</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>layoutViewport</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>pageY</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span>
|
1781
|
+
|
1782
|
+
<span class='id identifier rubyid_clip'>clip</span> <span class='op'>=</span> <span class='lbrace'>{</span>
|
1783
|
+
<span class='label'>x:</span> <span class='id identifier rubyid_page_x'>page_x</span> <span class='op'>+</span> <span class='id identifier rubyid_box'>box</span><span class='period'>.</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span>
|
1784
|
+
<span class='label'>y:</span> <span class='id identifier rubyid_page_y'>page_y</span> <span class='op'>+</span> <span class='id identifier rubyid_box'>box</span><span class='period'>.</span><span class='id identifier rubyid_y'>y</span><span class='comma'>,</span>
|
1785
|
+
<span class='label'>width:</span> <span class='id identifier rubyid_box'>box</span><span class='period'>.</span><span class='id identifier rubyid_width'>width</span><span class='comma'>,</span>
|
1786
|
+
<span class='label'>height:</span> <span class='id identifier rubyid_box'>box</span><span class='period'>.</span><span class='id identifier rubyid_height'>height</span><span class='comma'>,</span>
|
1787
|
+
<span class='rbrace'>}</span>
|
1788
|
+
|
1789
|
+
<span class='ivar'>@page</span><span class='period'>.</span><span class='id identifier rubyid_screenshot'>screenshot</span><span class='lparen'>(</span><span class='lbrace'>{</span> <span class='label'>clip:</span> <span class='id identifier rubyid_clip'>clip</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
1790
|
+
<span class='kw'>ensure</span>
|
1791
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_needs_viewport_reset'>needs_viewport_reset</span>
|
1792
|
+
<span class='ivar'>@page</span><span class='period'>.</span><span class='id identifier rubyid_viewport'>viewport</span> <span class='op'>=</span> <span class='id identifier rubyid_viewport'>viewport</span>
|
1175
1793
|
<span class='kw'>end</span>
|
1176
|
-
<span class='id identifier rubyid_handle'>handle</span><span class='period'>.</span><span class='id identifier rubyid_dispose'>dispose</span>
|
1177
|
-
<span class='kw'>nil</span>
|
1178
1794
|
<span class='kw'>end</span></pre>
|
1179
1795
|
</td>
|
1180
1796
|
</tr>
|
@@ -1196,10 +1812,6 @@
|
|
1196
1812
|
<pre class="lines">
|
1197
1813
|
|
1198
1814
|
|
1199
|
-
33
|
1200
|
-
34
|
1201
|
-
35
|
1202
|
-
36
|
1203
1815
|
37
|
1204
1816
|
38
|
1205
1817
|
39
|
@@ -1219,15 +1831,10 @@
|
|
1219
1831
|
53
|
1220
1832
|
54
|
1221
1833
|
55
|
1222
|
-
56
|
1223
|
-
57
|
1224
|
-
58
|
1225
|
-
59
|
1226
|
-
60
|
1227
|
-
61</pre>
|
1834
|
+
56</pre>
|
1228
1835
|
</td>
|
1229
1836
|
<td>
|
1230
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
1837
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 37</span>
|
1231
1838
|
|
1232
1839
|
<span class='kw'>def</span> <span class='id identifier rubyid_scroll_into_view_if_needed'>scroll_into_view_if_needed</span>
|
1233
1840
|
<span class='id identifier rubyid_js'>js</span> <span class='op'>=</span> <span class='heredoc_beg'><<~JAVASCRIPT</span>
|
@@ -1236,20 +1843,8 @@
|
|
1236
1843
|
</span><span class='tstring_content'> return 'Node is detached from document';
|
1237
1844
|
</span><span class='tstring_content'> if (element.nodeType !== Node.ELEMENT_NODE)
|
1238
1845
|
</span><span class='tstring_content'> return 'Node is not of type HTMLElement';
|
1239
|
-
</span><span class='tstring_content'>
|
1240
|
-
</span><span class='tstring_content'>
|
1241
|
-
</span><span class='tstring_content'> element.scrollIntoView({block: 'center', inline: 'center', behavior: 'instant'});
|
1242
|
-
</span><span class='tstring_content'> return false;
|
1243
|
-
</span><span class='tstring_content'> }
|
1244
|
-
</span><span class='tstring_content'> const visibleRatio = await new Promise(resolve => {
|
1245
|
-
</span><span class='tstring_content'> const observer = new IntersectionObserver(entries => {
|
1246
|
-
</span><span class='tstring_content'> resolve(entries[0].intersectionRatio);
|
1247
|
-
</span><span class='tstring_content'> observer.disconnect();
|
1248
|
-
</span><span class='tstring_content'> });
|
1249
|
-
</span><span class='tstring_content'> observer.observe(element);
|
1250
|
-
</span><span class='tstring_content'> });
|
1251
|
-
</span><span class='tstring_content'> if (visibleRatio !== 1.0)
|
1252
|
-
</span><span class='tstring_content'> element.scrollIntoView({block: 'center', inline: 'center', behavior: 'instant'});
|
1846
|
+
</span><span class='tstring_content'>
|
1847
|
+
</span><span class='tstring_content'> element.scrollIntoViewIfNeeded({block: 'center', inline: 'center', behavior: 'instant'});
|
1253
1848
|
</span><span class='tstring_content'> return false;
|
1254
1849
|
</span><span class='tstring_content'> }
|
1255
1850
|
</span><span class='heredoc_end'> JAVASCRIPT
|
@@ -1257,6 +1852,107 @@
|
|
1257
1852
|
</span> <span class='kw'>if</span> <span class='id identifier rubyid_error'>error</span>
|
1258
1853
|
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="ElementHandle/ScrollIntoViewError.html" title="Puppeteer::ElementHandle::ScrollIntoViewError (class)">ScrollIntoViewError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="Puppeteer::ElementHandle#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_error'>error</span><span class='rparen'>)</span>
|
1259
1854
|
<span class='kw'>end</span>
|
1855
|
+
<span class='comment'># clickpoint is often calculated before scrolling is completed.
|
1856
|
+
</span> <span class='comment'># So, just sleep about 10 frames
|
1857
|
+
</span> <span class='id identifier rubyid_sleep'>sleep</span> <span class='float'>0.16</span>
|
1858
|
+
<span class='kw'>end</span></pre>
|
1859
|
+
</td>
|
1860
|
+
</tr>
|
1861
|
+
</table>
|
1862
|
+
</div>
|
1863
|
+
|
1864
|
+
<div class="method_details ">
|
1865
|
+
<h3 class="signature " id="select-instance_method">
|
1866
|
+
|
1867
|
+
#<strong>select</strong>(*values) ⇒ <tt>Array<String></tt>
|
1868
|
+
|
1869
|
+
|
1870
|
+
|
1871
|
+
|
1872
|
+
|
1873
|
+
</h3><div class="docstring">
|
1874
|
+
<div class="discussion">
|
1875
|
+
|
1876
|
+
|
1877
|
+
</div>
|
1878
|
+
</div>
|
1879
|
+
<div class="tags">
|
1880
|
+
|
1881
|
+
<p class="tag_title">Returns:</p>
|
1882
|
+
<ul class="return">
|
1883
|
+
|
1884
|
+
<li>
|
1885
|
+
|
1886
|
+
|
1887
|
+
<span class='type'>(<tt>Array<String></tt>)</span>
|
1888
|
+
|
1889
|
+
|
1890
|
+
|
1891
|
+
</li>
|
1892
|
+
|
1893
|
+
</ul>
|
1894
|
+
|
1895
|
+
</div><table class="source_code">
|
1896
|
+
<tr>
|
1897
|
+
<td>
|
1898
|
+
<pre class="lines">
|
1899
|
+
|
1900
|
+
|
1901
|
+
131
|
1902
|
+
132
|
1903
|
+
133
|
1904
|
+
134
|
1905
|
+
135
|
1906
|
+
136
|
1907
|
+
137
|
1908
|
+
138
|
1909
|
+
139
|
1910
|
+
140
|
1911
|
+
141
|
1912
|
+
142
|
1913
|
+
143
|
1914
|
+
144
|
1915
|
+
145
|
1916
|
+
146
|
1917
|
+
147
|
1918
|
+
148
|
1919
|
+
149
|
1920
|
+
150
|
1921
|
+
151
|
1922
|
+
152
|
1923
|
+
153
|
1924
|
+
154
|
1925
|
+
155
|
1926
|
+
156</pre>
|
1927
|
+
</td>
|
1928
|
+
<td>
|
1929
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 131</span>
|
1930
|
+
|
1931
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_select'>select</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_values'>values</span><span class='rparen'>)</span>
|
1932
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_nonstring'>nonstring</span> <span class='op'>=</span> <span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_value'>value</span><span class='op'>|</span> <span class='op'>!</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
1933
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Values must be strings. Found value \"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_nonstring'>nonstring</span><span class='embexpr_end'>}</span><span class='tstring_content'>\" of type \"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_nonstring'>nonstring</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='embexpr_end'>}</span><span class='tstring_content'>\"</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1934
|
+
<span class='kw'>end</span>
|
1935
|
+
|
1936
|
+
<span class='id identifier rubyid_fn'>fn</span> <span class='op'>=</span> <span class='heredoc_beg'><<~JAVASCRIPT</span>
|
1937
|
+
<span class='tstring_content'> (element, values) => {
|
1938
|
+
</span><span class='tstring_content'> if (element.nodeName.toLowerCase() !== 'select') {
|
1939
|
+
</span><span class='tstring_content'> throw new Error('Element is not a <select> element.');
|
1940
|
+
</span><span class='tstring_content'> }
|
1941
|
+
</span><span class='tstring_content'>
|
1942
|
+
</span><span class='tstring_content'> const options = Array.from(element.options);
|
1943
|
+
</span><span class='tstring_content'> element.value = undefined;
|
1944
|
+
</span><span class='tstring_content'> for (const option of options) {
|
1945
|
+
</span><span class='tstring_content'> option.selected = values.includes(option.value);
|
1946
|
+
</span><span class='tstring_content'> if (option.selected && !element.multiple) {
|
1947
|
+
</span><span class='tstring_content'> break;
|
1948
|
+
</span><span class='tstring_content'> }
|
1949
|
+
</span><span class='tstring_content'> }
|
1950
|
+
</span><span class='tstring_content'> element.dispatchEvent(new Event('input', { bubbles: true }));
|
1951
|
+
</span><span class='tstring_content'> element.dispatchEvent(new Event('change', { bubbles: true }));
|
1952
|
+
</span><span class='tstring_content'> return options.filter(option => option.selected).map(option => option.value);
|
1953
|
+
</span><span class='tstring_content'> }
|
1954
|
+
</span><span class='heredoc_end'> JAVASCRIPT
|
1955
|
+
</span> <span class='id identifier rubyid_evaluate'>evaluate</span><span class='lparen'>(</span><span class='id identifier rubyid_fn'>fn</span><span class='comma'>,</span> <span class='id identifier rubyid_values'>values</span><span class='rparen'>)</span>
|
1260
1956
|
<span class='kw'>end</span></pre>
|
1261
1957
|
</td>
|
1262
1958
|
</tr>
|
@@ -1328,19 +2024,19 @@
|
|
1328
2024
|
<pre class="lines">
|
1329
2025
|
|
1330
2026
|
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
2027
|
+
348
|
2028
|
+
349
|
2029
|
+
350
|
2030
|
+
351
|
2031
|
+
352
|
2032
|
+
353
|
2033
|
+
354
|
2034
|
+
355
|
2035
|
+
356
|
2036
|
+
357</pre>
|
1341
2037
|
</td>
|
1342
2038
|
<td>
|
1343
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
2039
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 348</span>
|
1344
2040
|
|
1345
2041
|
<span class='kw'>def</span> <span class='const'>Seval</span><span class='lparen'>(</span><span class='id identifier rubyid_selector'>selector</span><span class='comma'>,</span> <span class='id identifier rubyid_page_function'>page_function</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
1346
2042
|
<span class='id identifier rubyid_element_handle'>element_handle</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="#S-instance_method" title="Puppeteer::ElementHandle#S (method)">S</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_selector'>selector</span><span class='rparen'>)</span>
|
@@ -1398,18 +2094,18 @@
|
|
1398
2094
|
<pre class="lines">
|
1399
2095
|
|
1400
2096
|
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
2097
|
+
328
|
2098
|
+
329
|
2099
|
+
330
|
2100
|
+
331
|
2101
|
+
332
|
2102
|
+
333
|
2103
|
+
334
|
2104
|
+
335
|
2105
|
+
336</pre>
|
1410
2106
|
</td>
|
1411
2107
|
<td>
|
1412
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
2108
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 328</span>
|
1413
2109
|
|
1414
2110
|
<span class='kw'>def</span> <span class='const'>SS</span><span class='lparen'>(</span><span class='id identifier rubyid_selector'>selector</span><span class='rparen'>)</span>
|
1415
2111
|
<span class='id identifier rubyid_handles'>handles</span> <span class='op'>=</span> <span class='id identifier rubyid_evaluate_handle'>evaluate_handle</span><span class='lparen'>(</span>
|
@@ -1490,19 +2186,19 @@
|
|
1490
2186
|
<pre class="lines">
|
1491
2187
|
|
1492
2188
|
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
2189
|
+
371
|
2190
|
+
372
|
2191
|
+
373
|
2192
|
+
374
|
2193
|
+
375
|
2194
|
+
376
|
2195
|
+
377
|
2196
|
+
378
|
2197
|
+
379
|
2198
|
+
380</pre>
|
1503
2199
|
</td>
|
1504
2200
|
<td>
|
1505
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
2201
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 371</span>
|
1506
2202
|
|
1507
2203
|
<span class='kw'>def</span> <span class='const'>SSeval</span><span class='lparen'>(</span><span class='id identifier rubyid_selector'>selector</span><span class='comma'>,</span> <span class='id identifier rubyid_page_function'>page_function</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
1508
2204
|
<span class='id identifier rubyid_handles'>handles</span> <span class='op'>=</span> <span class='id identifier rubyid_evaluate_handle'>evaluate_handle</span><span class='lparen'>(</span>
|
@@ -1517,6 +2213,141 @@
|
|
1517
2213
|
</td>
|
1518
2214
|
</tr>
|
1519
2215
|
</table>
|
2216
|
+
</div>
|
2217
|
+
|
2218
|
+
<div class="method_details ">
|
2219
|
+
<h3 class="signature " id="Sx-instance_method">
|
2220
|
+
|
2221
|
+
#<strong>Sx</strong>(expression) ⇒ <tt>Array<<span class='object_link'><a href="" title="Puppeteer::ElementHandle (class)">ElementHandle</a></span>></tt>
|
2222
|
+
|
2223
|
+
|
2224
|
+
|
2225
|
+
|
2226
|
+
|
2227
|
+
</h3><div class="docstring">
|
2228
|
+
<div class="discussion">
|
2229
|
+
|
2230
|
+
<p>`$x()` in JavaScript. $ is not allowed to use as a method name in Ruby.</p>
|
2231
|
+
|
2232
|
+
|
2233
|
+
</div>
|
2234
|
+
</div>
|
2235
|
+
<div class="tags">
|
2236
|
+
<p class="tag_title">Parameters:</p>
|
2237
|
+
<ul class="param">
|
2238
|
+
|
2239
|
+
<li>
|
2240
|
+
|
2241
|
+
<span class='name'>expression</span>
|
2242
|
+
|
2243
|
+
|
2244
|
+
<span class='type'>(<tt>String</tt>)</span>
|
2245
|
+
|
2246
|
+
|
2247
|
+
|
2248
|
+
</li>
|
2249
|
+
|
2250
|
+
</ul>
|
2251
|
+
|
2252
|
+
<p class="tag_title">Returns:</p>
|
2253
|
+
<ul class="return">
|
2254
|
+
|
2255
|
+
<li>
|
2256
|
+
|
2257
|
+
|
2258
|
+
<span class='type'>(<tt>Array<<span class='object_link'><a href="" title="Puppeteer::ElementHandle (class)">ElementHandle</a></span>></tt>)</span>
|
2259
|
+
|
2260
|
+
|
2261
|
+
|
2262
|
+
</li>
|
2263
|
+
|
2264
|
+
</ul>
|
2265
|
+
|
2266
|
+
</div><table class="source_code">
|
2267
|
+
<tr>
|
2268
|
+
<td>
|
2269
|
+
<pre class="lines">
|
2270
|
+
|
2271
|
+
|
2272
|
+
393
|
2273
|
+
394
|
2274
|
+
395
|
2275
|
+
396
|
2276
|
+
397
|
2277
|
+
398
|
2278
|
+
399
|
2279
|
+
400
|
2280
|
+
401
|
2281
|
+
402
|
2282
|
+
403
|
2283
|
+
404
|
2284
|
+
405
|
2285
|
+
406
|
2286
|
+
407
|
2287
|
+
408
|
2288
|
+
409</pre>
|
2289
|
+
</td>
|
2290
|
+
<td>
|
2291
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 393</span>
|
2292
|
+
|
2293
|
+
<span class='kw'>def</span> <span class='const'>Sx</span><span class='lparen'>(</span><span class='id identifier rubyid_expression'>expression</span><span class='rparen'>)</span>
|
2294
|
+
<span class='id identifier rubyid_fn'>fn</span> <span class='op'>=</span> <span class='heredoc_beg'><<~JAVASCRIPT</span>
|
2295
|
+
<span class='tstring_content'> (element, expression) => {
|
2296
|
+
</span><span class='tstring_content'> const document = element.ownerDocument || element;
|
2297
|
+
</span><span class='tstring_content'> const iterator = document.evaluate(expression, element, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE);
|
2298
|
+
</span><span class='tstring_content'> const array = [];
|
2299
|
+
</span><span class='tstring_content'> let item;
|
2300
|
+
</span><span class='tstring_content'> while ((item = iterator.iterateNext()))
|
2301
|
+
</span><span class='tstring_content'> array.push(item);
|
2302
|
+
</span><span class='tstring_content'> return array;
|
2303
|
+
</span><span class='tstring_content'> }
|
2304
|
+
</span><span class='heredoc_end'> JAVASCRIPT
|
2305
|
+
</span> <span class='id identifier rubyid_handles'>handles</span> <span class='op'>=</span> <span class='id identifier rubyid_evaluate_handle'>evaluate_handle</span><span class='lparen'>(</span><span class='id identifier rubyid_fn'>fn</span><span class='comma'>,</span> <span class='id identifier rubyid_expression'>expression</span><span class='rparen'>)</span>
|
2306
|
+
<span class='id identifier rubyid_properties'>properties</span> <span class='op'>=</span> <span class='id identifier rubyid_handles'>handles</span><span class='period'>.</span><span class='id identifier rubyid_properties'>properties</span>
|
2307
|
+
<span class='id identifier rubyid_handles'>handles</span><span class='period'>.</span><span class='id identifier rubyid_dispose'>dispose</span>
|
2308
|
+
<span class='id identifier rubyid_properties'>properties</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:as_element</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span>
|
2309
|
+
<span class='kw'>end</span></pre>
|
2310
|
+
</td>
|
2311
|
+
</tr>
|
2312
|
+
</table>
|
2313
|
+
</div>
|
2314
|
+
|
2315
|
+
<div class="method_details ">
|
2316
|
+
<h3 class="signature " id="tap-instance_method">
|
2317
|
+
|
2318
|
+
#<strong>tap</strong>(&block) ⇒ <tt>Object</tt>
|
2319
|
+
|
2320
|
+
|
2321
|
+
|
2322
|
+
|
2323
|
+
|
2324
|
+
</h3><table class="source_code">
|
2325
|
+
<tr>
|
2326
|
+
<td>
|
2327
|
+
<pre class="lines">
|
2328
|
+
|
2329
|
+
|
2330
|
+
190
|
2331
|
+
191
|
2332
|
+
192
|
2333
|
+
193
|
2334
|
+
194
|
2335
|
+
195
|
2336
|
+
196</pre>
|
2337
|
+
</td>
|
2338
|
+
<td>
|
2339
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 190</span>
|
2340
|
+
|
2341
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_tap'>tap</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
2342
|
+
<span class='kw'>return</span> <span class='kw'>super</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_block'>block</span>
|
2343
|
+
|
2344
|
+
<span class='id identifier rubyid_scroll_into_view_if_needed'>scroll_into_view_if_needed</span>
|
2345
|
+
<span class='id identifier rubyid_point'>point</span> <span class='op'>=</span> <span class='id identifier rubyid_clickable_point'>clickable_point</span>
|
2346
|
+
<span class='ivar'>@page</span><span class='period'>.</span><span class='id identifier rubyid_touchscreen'>touchscreen</span><span class='period'>.</span><span class='id identifier rubyid_tap'>tap</span><span class='lparen'>(</span><span class='id identifier rubyid_point'>point</span><span class='period'>.</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_point'>point</span><span class='period'>.</span><span class='id identifier rubyid_y'>y</span><span class='rparen'>)</span>
|
2347
|
+
<span class='kw'>end</span></pre>
|
2348
|
+
</td>
|
2349
|
+
</tr>
|
2350
|
+
</table>
|
1520
2351
|
</div>
|
1521
2352
|
|
1522
2353
|
<div class="method_details ">
|
@@ -1571,13 +2402,13 @@
|
|
1571
2402
|
<pre class="lines">
|
1572
2403
|
|
1573
2404
|
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
2405
|
+
212
|
2406
|
+
213
|
2407
|
+
214
|
2408
|
+
215</pre>
|
1578
2409
|
</td>
|
1579
2410
|
<td>
|
1580
|
-
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line
|
2411
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 212</span>
|
1581
2412
|
|
1582
2413
|
<span class='kw'>def</span> <span class='id identifier rubyid_type_text'>type_text</span><span class='lparen'>(</span><span class='id identifier rubyid_text'>text</span><span class='comma'>,</span> <span class='label'>delay:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
1583
2414
|
<span class='id identifier rubyid_focus'>focus</span>
|
@@ -1586,6 +2417,114 @@
|
|
1586
2417
|
</td>
|
1587
2418
|
</tr>
|
1588
2419
|
</table>
|
2420
|
+
</div>
|
2421
|
+
|
2422
|
+
<div class="method_details ">
|
2423
|
+
<h3 class="signature " id="upload_file-instance_method">
|
2424
|
+
|
2425
|
+
#<strong>upload_file</strong>(*file_paths) ⇒ <tt>Object</tt>
|
2426
|
+
|
2427
|
+
|
2428
|
+
|
2429
|
+
|
2430
|
+
|
2431
|
+
</h3><div class="docstring">
|
2432
|
+
<div class="discussion">
|
2433
|
+
|
2434
|
+
|
2435
|
+
</div>
|
2436
|
+
</div>
|
2437
|
+
<div class="tags">
|
2438
|
+
<p class="tag_title">Parameters:</p>
|
2439
|
+
<ul class="param">
|
2440
|
+
|
2441
|
+
<li>
|
2442
|
+
|
2443
|
+
<span class='name'>file_paths</span>
|
2444
|
+
|
2445
|
+
|
2446
|
+
<span class='type'>(<tt>Array<String></tt>)</span>
|
2447
|
+
|
2448
|
+
|
2449
|
+
|
2450
|
+
</li>
|
2451
|
+
|
2452
|
+
</ul>
|
2453
|
+
|
2454
|
+
|
2455
|
+
</div><table class="source_code">
|
2456
|
+
<tr>
|
2457
|
+
<td>
|
2458
|
+
<pre class="lines">
|
2459
|
+
|
2460
|
+
|
2461
|
+
159
|
2462
|
+
160
|
2463
|
+
161
|
2464
|
+
162
|
2465
|
+
163
|
2466
|
+
164
|
2467
|
+
165
|
2468
|
+
166
|
2469
|
+
167
|
2470
|
+
168
|
2471
|
+
169
|
2472
|
+
170
|
2473
|
+
171
|
2474
|
+
172
|
2475
|
+
173
|
2476
|
+
174
|
2477
|
+
175
|
2478
|
+
176
|
2479
|
+
177
|
2480
|
+
178
|
2481
|
+
179
|
2482
|
+
180
|
2483
|
+
181
|
2484
|
+
182
|
2485
|
+
183
|
2486
|
+
184
|
2487
|
+
185
|
2488
|
+
186
|
2489
|
+
187
|
2490
|
+
188</pre>
|
2491
|
+
</td>
|
2492
|
+
<td>
|
2493
|
+
<pre class="code"><span class="info file"># File 'lib/puppeteer/element_handle.rb', line 159</span>
|
2494
|
+
|
2495
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_upload_file'>upload_file</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_file_paths'>file_paths</span><span class='rparen'>)</span>
|
2496
|
+
<span class='id identifier rubyid_is_multiple'>is_multiple</span> <span class='op'>=</span> <span class='id identifier rubyid_evaluate'>evaluate</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>el => el.multiple</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
2497
|
+
<span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_is_multiple'>is_multiple</span> <span class='op'>&&</span> <span class='id identifier rubyid_file_paths'>file_paths</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>>=</span> <span class='int'>2</span>
|
2498
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Multiple file uploads only work with <input type=file multiple></span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
2499
|
+
<span class='kw'>end</span>
|
2500
|
+
|
2501
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_error_path'>error_path</span> <span class='op'>=</span> <span class='id identifier rubyid_file_paths'>file_paths</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_file_path'>file_path</span><span class='op'>|</span> <span class='op'>!</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exist?'>exist?</span><span class='lparen'>(</span><span class='id identifier rubyid_file_path'>file_path</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
2502
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgmentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_error_path'>error_path</span><span class='embexpr_end'>}</span><span class='tstring_content'> does not exist or is not readable</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
2503
|
+
<span class='kw'>end</span>
|
2504
|
+
|
2505
|
+
<span class='id identifier rubyid_backend_node_id'>backend_node_id</span> <span class='op'>=</span> <span class='ivar'>@remote_object</span><span class='period'>.</span><span class='id identifier rubyid_node_info'>node_info</span><span class='lparen'>(</span><span class='ivar'>@client</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>node</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>backendNodeId</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span>
|
2506
|
+
|
2507
|
+
<span class='comment'># The zero-length array is a special case, it seems that DOM.setFileInputFiles does
|
2508
|
+
</span> <span class='comment'># not actually update the files in that case, so the solution is to eval the element
|
2509
|
+
</span> <span class='comment'># value to a new FileList directly.
|
2510
|
+
</span> <span class='kw'>if</span> <span class='id identifier rubyid_file_paths'>file_paths</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
|
2511
|
+
<span class='id identifier rubyid_fn'>fn</span> <span class='op'>=</span> <span class='heredoc_beg'><<~JAVASCRIPT</span>
|
2512
|
+
<span class='tstring_content'> (element) => {
|
2513
|
+
</span><span class='tstring_content'> element.files = new DataTransfer().files;
|
2514
|
+
</span><span class='tstring_content'>
|
2515
|
+
</span><span class='tstring_content'> // Dispatch events for this case because it should behave akin to a user action.
|
2516
|
+
</span><span class='tstring_content'> element.dispatchEvent(new Event('input', { bubbles: true }));
|
2517
|
+
</span><span class='tstring_content'> element.dispatchEvent(new Event('change', { bubbles: true }));
|
2518
|
+
</span><span class='tstring_content'> }
|
2519
|
+
</span><span class='heredoc_end'> JAVASCRIPT
|
2520
|
+
</span> <span class='id identifier rubyid_await'><span class='object_link'><a href="ConcurrentRubyUtils.html#await-instance_method" title="Puppeteer::ConcurrentRubyUtils#await (method)">await</a></span></span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_evaluate'>evaluate</span><span class='lparen'>(</span><span class='id identifier rubyid_fn'>fn</span><span class='rparen'>)</span>
|
2521
|
+
<span class='kw'>else</span>
|
2522
|
+
<span class='ivar'>@remote_object</span><span class='period'>.</span><span class='id identifier rubyid_set_file_input_files'>set_file_input_files</span><span class='lparen'>(</span><span class='ivar'>@client</span><span class='comma'>,</span> <span class='id identifier rubyid_file_paths'>file_paths</span><span class='comma'>,</span> <span class='id identifier rubyid_backend_node_id'>backend_node_id</span><span class='rparen'>)</span>
|
2523
|
+
<span class='kw'>end</span>
|
2524
|
+
<span class='kw'>end</span></pre>
|
2525
|
+
</td>
|
2526
|
+
</tr>
|
2527
|
+
</table>
|
1589
2528
|
</div>
|
1590
2529
|
|
1591
2530
|
</div>
|
@@ -1593,7 +2532,7 @@
|
|
1593
2532
|
</div>
|
1594
2533
|
|
1595
2534
|
<div id="footer">
|
1596
|
-
Generated on
|
2535
|
+
Generated on Sat Jun 20 17:15:07 2020 by
|
1597
2536
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1598
2537
|
0.9.24 (ruby-2.6.3).
|
1599
2538
|
</div>
|