ferrum 0.9 → 0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +110 -74
- data/lib/ferrum.rb +17 -8
- data/lib/ferrum/browser.rb +6 -5
- data/lib/ferrum/browser/client.rb +4 -0
- data/lib/ferrum/browser/command.rb +1 -1
- data/lib/ferrum/browser/process.rb +5 -3
- data/lib/ferrum/browser/subscriber.rb +4 -0
- data/lib/ferrum/context.rb +3 -3
- data/lib/ferrum/frame.rb +1 -0
- data/lib/ferrum/frame/dom.rb +30 -30
- data/lib/ferrum/frame/runtime.rb +54 -71
- data/lib/ferrum/network.rb +23 -6
- data/lib/ferrum/network/error.rb +8 -15
- data/lib/ferrum/node.rb +11 -0
- data/lib/ferrum/page.rb +23 -11
- data/lib/ferrum/page/frames.rb +5 -2
- data/lib/ferrum/page/screenshot.rb +62 -10
- data/lib/ferrum/rbga.rb +38 -0
- data/lib/ferrum/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c605388d1ea1a0f54f5f1ef24e56a93b60d109ec6eb02798d9de606cd54c29ef
|
4
|
+
data.tar.gz: a0cb3328ad526e51beaefb5eb8140659b1dd277acda5305f46464200d02ed24a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3e44b234a458079b268b7af941af8404a7aa9e6ade2d018ca07fdabcc21518a5d1ad6daafbcdcd3ed7dffe5f94f9b5a4fef36aa1b317178b1604df7f96a8a2b
|
7
|
+
data.tar.gz: 8b4ea9e0c5b0d029d743b1314dba4b6111f87f26ac4cb5c87e1b06d04b9693fc0570908456c4ced0860b07cc748d8ba783b320481d2879ec5df7b65ec70e85ec
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# Ferrum - high-level API to control Chrome in Ruby
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/rubycdp/ferrum.svg?branch=master)](https://travis-ci.org/rubycdp/ferrum)
|
4
|
-
|
5
3
|
<img align="right"
|
6
4
|
width="320" height="241"
|
7
5
|
alt="Ferrum logo"
|
@@ -32,9 +30,6 @@ Web design by [Evrone](https://evrone.com/), what else
|
|
32
30
|
[we build with Ruby on Rails](https://evrone.com/ruby), what else
|
33
31
|
[we do at Evrone](https://evrone.com/cases#case-studies).
|
34
32
|
|
35
|
-
If you like this project, please consider to
|
36
|
-
_[become a backer](https://www.patreon.com/rubycdp_ferrum)_ on Patreon.
|
37
|
-
|
38
33
|
|
39
34
|
## Index
|
40
35
|
|
@@ -55,6 +50,8 @@ _[become a backer](https://www.patreon.com/rubycdp_ferrum)_ on Patreon.
|
|
55
50
|
* [Frame](https://github.com/rubycdp/ferrum#frame)
|
56
51
|
* [Dialog](https://github.com/rubycdp/ferrum#dialog)
|
57
52
|
* [Thread safety](https://github.com/rubycdp/ferrum#thread-safety)
|
53
|
+
* [Development](https://github.com/rubycdp/ferrum#development)
|
54
|
+
* [Contributing](https://github.com/rubycdp/ferrum#contributing)
|
58
55
|
* [License](https://github.com/rubycdp/ferrum#license)
|
59
56
|
|
60
57
|
|
@@ -80,7 +77,7 @@ Navigate to a website and save a screenshot:
|
|
80
77
|
|
81
78
|
```ruby
|
82
79
|
browser = Ferrum::Browser.new
|
83
|
-
browser.
|
80
|
+
browser.go_to("https://google.com")
|
84
81
|
browser.screenshot(path: "google.png")
|
85
82
|
browser.quit
|
86
83
|
```
|
@@ -89,7 +86,7 @@ Interact with a page:
|
|
89
86
|
|
90
87
|
```ruby
|
91
88
|
browser = Ferrum::Browser.new
|
92
|
-
browser.
|
89
|
+
browser.go_to("https://google.com")
|
93
90
|
input = browser.at_xpath("//input[@name='q']")
|
94
91
|
input.focus.type("Ruby headless driver for Chrome", :Enter)
|
95
92
|
browser.at_css("a > h3").text # => "rubycdp/ferrum: Ruby Chrome/Chromium driver - GitHub"
|
@@ -100,7 +97,7 @@ Evaluate some JavaScript and get full width/height:
|
|
100
97
|
|
101
98
|
```ruby
|
102
99
|
browser = Ferrum::Browser.new
|
103
|
-
browser.
|
100
|
+
browser.go_to("https://www.google.com/search?q=Ruby+headless+driver+for+Capybara")
|
104
101
|
width, height = browser.evaluate <<~JS
|
105
102
|
[document.documentElement.offsetWidth,
|
106
103
|
document.documentElement.offsetHeight]
|
@@ -114,7 +111,7 @@ Do any mouse movements you like:
|
|
114
111
|
```ruby
|
115
112
|
# Trace a 100x100 square
|
116
113
|
browser = Ferrum::Browser.new
|
117
|
-
browser.
|
114
|
+
browser.go_to("https://google.com")
|
118
115
|
browser.mouse
|
119
116
|
.move(x: 0, y: 0)
|
120
117
|
.down
|
@@ -155,11 +152,14 @@ Ferrum::Browser.new(options)
|
|
155
152
|
`["/path/to/script.js", { source: "window.secret = 'top'" }]`
|
156
153
|
* `:logger` (Object responding to `puts`) - When present, debug output is
|
157
154
|
written to this object.
|
158
|
-
* `:slowmo` (Integer | Float) - Set a delay to wait before sending command.
|
155
|
+
* `:slowmo` (Integer | Float) - Set a delay in seconds to wait before sending command.
|
159
156
|
Usefull companion of headless option, so that you have time to see changes.
|
160
157
|
* `:timeout` (Numeric) - The number of seconds we'll wait for a response when
|
161
158
|
communicating with browser. Default is 5.
|
162
159
|
* `:js_errors` (Boolean) - When true, JavaScript errors get re-raised in Ruby.
|
160
|
+
* `:pending_connection_errors` (Boolean) - When main frame is still waiting for slow responses while timeout is
|
161
|
+
reached `PendingConnectionsError` is raised. It's better to figure out why you have slow responses and fix or
|
162
|
+
block them rather than turn this setting off. Default is true.
|
163
163
|
* `:browser_name` (Symbol) - `:chrome` by default, only experimental support
|
164
164
|
for `:firefox` for now.
|
165
165
|
* `:browser_path` (String) - Path to Chrome binary, you can also set ENV
|
@@ -184,7 +184,7 @@ Ferrum::Browser.new(options)
|
|
184
184
|
|
185
185
|
## Navigation
|
186
186
|
|
187
|
-
####
|
187
|
+
#### go_to(url) : `String`
|
188
188
|
|
189
189
|
Navigate page to.
|
190
190
|
|
@@ -192,7 +192,7 @@ Navigate page to.
|
|
192
192
|
configuring driver.
|
193
193
|
|
194
194
|
```ruby
|
195
|
-
browser.
|
195
|
+
browser.go_to("https://github.com/")
|
196
196
|
```
|
197
197
|
|
198
198
|
#### back
|
@@ -200,7 +200,7 @@ browser.goto("https://github.com/")
|
|
200
200
|
Navigate to the previous page in history.
|
201
201
|
|
202
202
|
```ruby
|
203
|
-
browser.
|
203
|
+
browser.go_to("https://github.com/")
|
204
204
|
browser.at_xpath("//a").click
|
205
205
|
browser.back
|
206
206
|
```
|
@@ -210,7 +210,7 @@ browser.back
|
|
210
210
|
Navigate to the next page in history.
|
211
211
|
|
212
212
|
```ruby
|
213
|
-
browser.
|
213
|
+
browser.go_to("https://github.com/")
|
214
214
|
browser.at_xpath("//a").click
|
215
215
|
browser.back
|
216
216
|
browser.forward
|
@@ -221,7 +221,7 @@ browser.forward
|
|
221
221
|
Reload current page.
|
222
222
|
|
223
223
|
```ruby
|
224
|
-
browser.
|
224
|
+
browser.go_to("https://github.com/")
|
225
225
|
browser.refresh
|
226
226
|
```
|
227
227
|
|
@@ -230,7 +230,7 @@ browser.refresh
|
|
230
230
|
Stop all navigations and loading pending resources on the page
|
231
231
|
|
232
232
|
```ruby
|
233
|
-
browser.
|
233
|
+
browser.go_to("https://github.com/")
|
234
234
|
browser.stop
|
235
235
|
```
|
236
236
|
|
@@ -247,7 +247,7 @@ provided node.
|
|
247
247
|
* :within `Node` | `nil`
|
248
248
|
|
249
249
|
```ruby
|
250
|
-
browser.
|
250
|
+
browser.go_to("https://github.com/")
|
251
251
|
browser.at_css("a[aria-label='Issues you created']") # => Node
|
252
252
|
```
|
253
253
|
|
@@ -262,7 +262,7 @@ document or provided node.
|
|
262
262
|
* :within `Node` | `nil`
|
263
263
|
|
264
264
|
```ruby
|
265
|
-
browser.
|
265
|
+
browser.go_to("https://github.com/")
|
266
266
|
browser.css("a[aria-label='Issues you created']") # => [Node]
|
267
267
|
```
|
268
268
|
|
@@ -275,7 +275,7 @@ Find node by xpath.
|
|
275
275
|
* :within `Node` | `nil`
|
276
276
|
|
277
277
|
```ruby
|
278
|
-
browser.
|
278
|
+
browser.go_to("https://github.com/")
|
279
279
|
browser.at_xpath("//a[@aria-label='Issues you created']") # => Node
|
280
280
|
```
|
281
281
|
|
@@ -288,7 +288,7 @@ Find nodes by xpath.
|
|
288
288
|
* :within `Node` | `nil`
|
289
289
|
|
290
290
|
```ruby
|
291
|
-
browser.
|
291
|
+
browser.go_to("https://github.com/")
|
292
292
|
browser.xpath("//a[@aria-label='Issues you created']") # => [Node]
|
293
293
|
```
|
294
294
|
|
@@ -297,7 +297,7 @@ browser.xpath("//a[@aria-label='Issues you created']") # => [Node]
|
|
297
297
|
Returns current top window location href.
|
298
298
|
|
299
299
|
```ruby
|
300
|
-
browser.
|
300
|
+
browser.go_to("https://google.com/")
|
301
301
|
browser.current_url # => "https://www.google.com/"
|
302
302
|
```
|
303
303
|
|
@@ -306,7 +306,7 @@ browser.current_url # => "https://www.google.com/"
|
|
306
306
|
Returns current top window title
|
307
307
|
|
308
308
|
```ruby
|
309
|
-
browser.
|
309
|
+
browser.go_to("https://google.com/")
|
310
310
|
browser.current_title # => "Google"
|
311
311
|
```
|
312
312
|
|
@@ -315,7 +315,7 @@ browser.current_title # => "Google"
|
|
315
315
|
Returns current page's html.
|
316
316
|
|
317
317
|
```ruby
|
318
|
-
browser.
|
318
|
+
browser.go_to("https://google.com/")
|
319
319
|
browser.body # => '<html itemscope="" itemtype="http://schema.org/WebPage" lang="ru"><head>...
|
320
320
|
```
|
321
321
|
|
@@ -336,18 +336,21 @@ Saves screenshot on a disk or returns it as base64.
|
|
336
336
|
* :full `Boolean` whether you need full page screenshot or a viewport
|
337
337
|
* :selector `String` css selector for given element
|
338
338
|
* :scale `Float` zoom in/out
|
339
|
+
* :background_color `Ferrum::RGBA.new(0, 0, 0, 0.0)` to have specific background color
|
339
340
|
|
340
341
|
```ruby
|
341
|
-
browser.
|
342
|
+
browser.go_to("https://google.com/")
|
342
343
|
# Save on the disk in PNG
|
343
344
|
browser.screenshot(path: "google.png") # => 134660
|
344
345
|
# Save on the disk in JPG
|
345
346
|
browser.screenshot(path: "google.jpg") # => 30902
|
346
347
|
# Save to Base64 the whole page not only viewport and reduce quality
|
347
348
|
browser.screenshot(full: true, quality: 60) # "iVBORw0KGgoAAAANSUhEUgAABAAAAAMACAYAAAC6uhUNAAAAAXNSR0IArs4c6Q...
|
349
|
+
# Save with specific background color
|
350
|
+
browser.screenshot(background_color: Ferrum::RGBA.new(0, 0, 0, 0.0))
|
348
351
|
```
|
349
352
|
|
350
|
-
#### pdf(\*\*options) : `String` | `
|
353
|
+
#### pdf(\*\*options) : `String` | `Boolean`
|
351
354
|
|
352
355
|
Saves PDF on a disk or returns it as base64.
|
353
356
|
|
@@ -365,9 +368,21 @@ Saves PDF on a disk or returns it as base64.
|
|
365
368
|
* See other [native options](https://chromedevtools.github.io/devtools-protocol/tot/Page#method-printToPDF) you can pass
|
366
369
|
|
367
370
|
```ruby
|
368
|
-
browser.
|
371
|
+
browser.go_to("https://google.com/")
|
369
372
|
# Save to disk as a PDF
|
370
|
-
browser.pdf(path: "google.pdf", paper_width: 1.0, paper_height: 1.0) # =>
|
373
|
+
browser.pdf(path: "google.pdf", paper_width: 1.0, paper_height: 1.0) # => true
|
374
|
+
```
|
375
|
+
|
376
|
+
#### mhtml(\*\*options) : `String` | `Integer`
|
377
|
+
|
378
|
+
Saves MHTML on a disk or returns it as a string.
|
379
|
+
|
380
|
+
* options `Hash`
|
381
|
+
* :path `String` to save a file on the disk.
|
382
|
+
|
383
|
+
```ruby
|
384
|
+
browser.go_to("https://google.com/")
|
385
|
+
browser.mhtml(path: "google.mhtml") # => 87742
|
371
386
|
```
|
372
387
|
|
373
388
|
|
@@ -381,7 +396,7 @@ Returns all information about network traffic as `Network::Exchange` instance
|
|
381
396
|
which in general is a wrapper around `request`, `response` and `error`.
|
382
397
|
|
383
398
|
```ruby
|
384
|
-
browser.
|
399
|
+
browser.go_to("https://github.com/")
|
385
400
|
browser.network.traffic # => [#<Ferrum::Network::Exchange, ...]
|
386
401
|
```
|
387
402
|
|
@@ -390,7 +405,7 @@ browser.network.traffic # => [#<Ferrum::Network::Exchange, ...]
|
|
390
405
|
Page request of the main frame.
|
391
406
|
|
392
407
|
```ruby
|
393
|
-
browser.
|
408
|
+
browser.go_to("https://github.com/")
|
394
409
|
browser.network.request # => #<Ferrum::Network::Request...
|
395
410
|
```
|
396
411
|
|
@@ -399,7 +414,7 @@ browser.network.request # => #<Ferrum::Network::Request...
|
|
399
414
|
Page response of the main frame.
|
400
415
|
|
401
416
|
```ruby
|
402
|
-
browser.
|
417
|
+
browser.go_to("https://github.com/")
|
403
418
|
browser.network.response # => #<Ferrum::Network::Response...
|
404
419
|
```
|
405
420
|
|
@@ -409,7 +424,7 @@ Contains the status code of the main page response (e.g., 200 for a
|
|
409
424
|
success). This is just a shortcut for `response.status`.
|
410
425
|
|
411
426
|
```ruby
|
412
|
-
browser.
|
427
|
+
browser.go_to("https://github.com/")
|
413
428
|
browser.network.status # => 200
|
414
429
|
```
|
415
430
|
|
@@ -426,7 +441,7 @@ Waits for network idle or raises `Ferrum::TimeoutError` error
|
|
426
441
|
by default
|
427
442
|
|
428
443
|
```ruby
|
429
|
-
browser.
|
444
|
+
browser.go_to("https://example.com/")
|
430
445
|
browser.at_xpath("//a[text() = 'No UI changes button']").click
|
431
446
|
browser.network.wait_for_idle
|
432
447
|
```
|
@@ -439,7 +454,7 @@ Clear browser's cache or collected traffic.
|
|
439
454
|
|
440
455
|
```ruby
|
441
456
|
traffic = browser.network.traffic # => []
|
442
|
-
browser.
|
457
|
+
browser.go_to("https://github.com/")
|
443
458
|
traffic.size # => 51
|
444
459
|
browser.network.clear(:traffic)
|
445
460
|
traffic.size # => 0
|
@@ -467,25 +482,52 @@ browser.on(:request) do |request|
|
|
467
482
|
request.continue
|
468
483
|
end
|
469
484
|
end
|
470
|
-
browser.
|
485
|
+
browser.go_to("https://google.com")
|
471
486
|
```
|
472
487
|
|
473
|
-
#### authorize(\*\*options)
|
488
|
+
#### authorize(\*\*options, &block)
|
474
489
|
|
475
|
-
If site uses authorization you can provide credentials using this method.
|
490
|
+
If site or proxy uses authorization you can provide credentials using this method.
|
476
491
|
|
477
492
|
* options `Hash`
|
478
493
|
* :type `Symbol` `:server` | `:proxy` site or proxy authorization
|
479
494
|
* :user `String`
|
480
495
|
* :password `String`
|
496
|
+
* &block accepts authenticated request, which you must subsequently allow or deny, if you don't
|
497
|
+
care about unwanted requests just call `request.continue`.
|
481
498
|
|
482
499
|
```ruby
|
483
|
-
browser.network.authorize(user: "login", password: "pass")
|
484
|
-
browser.
|
500
|
+
browser.network.authorize(user: "login", password: "pass") { |req| req.continue }
|
501
|
+
browser.go_to("http://example.com/authenticated")
|
485
502
|
puts browser.network.status # => 200
|
486
503
|
puts browser.body # => Welcome, authenticated client
|
487
504
|
```
|
488
505
|
|
506
|
+
Since Chrome implements authorize using request interception you must continue or abort authorized requests. If you
|
507
|
+
already have code that uses interception you can use `authorize` without block, but if not you are obliged to pass
|
508
|
+
block, so this is version doesn't pass block and can work just fine:
|
509
|
+
|
510
|
+
```ruby
|
511
|
+
browser = Ferrum::Browser.new
|
512
|
+
browser.network.intercept
|
513
|
+
browser.on(:request) do |request|
|
514
|
+
if request.resource_type == "Image"
|
515
|
+
request.abort
|
516
|
+
else
|
517
|
+
request.continue
|
518
|
+
end
|
519
|
+
end
|
520
|
+
|
521
|
+
browser.network.authorize(user: "login", password: "pass", type: :proxy)
|
522
|
+
|
523
|
+
browser.go_to("https://google.com")
|
524
|
+
|
525
|
+
```
|
526
|
+
|
527
|
+
You used to call `authorize` method without block, but since it's implemented using request interception there could be
|
528
|
+
a collision with another part of your code that also uses request interception, so that authorize allows the request
|
529
|
+
while your code denies but it's too late. The block is mandatory now.
|
530
|
+
|
489
531
|
|
490
532
|
### Mouse
|
491
533
|
|
@@ -501,7 +543,7 @@ Scroll page to a given x, y
|
|
501
543
|
displayed in the upper left
|
502
544
|
|
503
545
|
```ruby
|
504
|
-
browser.
|
546
|
+
browser.go_to("https://www.google.com/search?q=Ruby+headless+driver+for+Capybara")
|
505
547
|
browser.mouse.scroll_to(0, 400)
|
506
548
|
```
|
507
549
|
|
@@ -727,7 +769,7 @@ browser.add_style_tag(content: "h1 { font-size: 40px; }") # => true
|
|
727
769
|
|
728
770
|
```ruby
|
729
771
|
browser.bypass_csp # => true
|
730
|
-
browser.
|
772
|
+
browser.go_to("https://github.com/ruby-concurrency/concurrent-ruby/blob/master/docs-source/promises.in.md")
|
731
773
|
browser.refresh
|
732
774
|
browser.add_script_tag(content: "window.__injected = 42")
|
733
775
|
browser.evaluate("window.__injected") # => 42
|
@@ -741,7 +783,7 @@ browser.evaluate("window.__injected") # => 42
|
|
741
783
|
Returns all the frames current page have.
|
742
784
|
|
743
785
|
```ruby
|
744
|
-
browser.
|
786
|
+
browser.go_to("https://www.w3schools.com/tags/tag_frame.asp")
|
745
787
|
browser.frames # =>
|
746
788
|
# [
|
747
789
|
# #<Ferrum::Frame @id="C6D104CE454A025FBCF22B98DE612B12" @parent_id=nil @name=nil @state=:stopped_loading @execution_id=1>,
|
@@ -800,7 +842,7 @@ One of the states frame's in:
|
|
800
842
|
Returns current frame's location href.
|
801
843
|
|
802
844
|
```ruby
|
803
|
-
browser.
|
845
|
+
browser.go_to("https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe")
|
804
846
|
frame = browser.frames[1]
|
805
847
|
frame.url # => https://interactive-examples.mdn.mozilla.net/pages/tabbed/iframe.html
|
806
848
|
```
|
@@ -810,7 +852,7 @@ frame.url # => https://interactive-examples.mdn.mozilla.net/pages/tabbed/iframe.
|
|
810
852
|
Returns current frame's title.
|
811
853
|
|
812
854
|
```ruby
|
813
|
-
browser.
|
855
|
+
browser.go_to("https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe")
|
814
856
|
frame = browser.frames[1]
|
815
857
|
frame.title # => HTML Demo: <iframe>
|
816
858
|
```
|
@@ -820,7 +862,7 @@ frame.title # => HTML Demo: <iframe>
|
|
820
862
|
If current frame is the main frame of the page (top of the tree).
|
821
863
|
|
822
864
|
```ruby
|
823
|
-
browser.
|
865
|
+
browser.go_to("https://www.w3schools.com/tags/tag_frame.asp")
|
824
866
|
frame = browser.frame_by(id: "C09C4E4404314AAEAE85928EAC109A93")
|
825
867
|
frame.main? # => false
|
826
868
|
```
|
@@ -830,7 +872,7 @@ frame.main? # => false
|
|
830
872
|
Returns current frame's top window location href.
|
831
873
|
|
832
874
|
```ruby
|
833
|
-
browser.
|
875
|
+
browser.go_to("https://www.w3schools.com/tags/tag_frame.asp")
|
834
876
|
frame = browser.frame_by(id: "C09C4E4404314AAEAE85928EAC109A93")
|
835
877
|
frame.current_url # => "https://www.w3schools.com/tags/tag_frame.asp"
|
836
878
|
```
|
@@ -840,7 +882,7 @@ frame.current_url # => "https://www.w3schools.com/tags/tag_frame.asp"
|
|
840
882
|
Returns current frame's top window title.
|
841
883
|
|
842
884
|
```ruby
|
843
|
-
browser.
|
885
|
+
browser.go_to("https://www.w3schools.com/tags/tag_frame.asp")
|
844
886
|
frame = browser.frame_by(id: "C09C4E4404314AAEAE85928EAC109A93")
|
845
887
|
frame.current_title # => "HTML frame tag"
|
846
888
|
```
|
@@ -850,7 +892,7 @@ frame.current_title # => "HTML frame tag"
|
|
850
892
|
Returns current frame's html.
|
851
893
|
|
852
894
|
```ruby
|
853
|
-
browser.
|
895
|
+
browser.go_to("https://www.w3schools.com/tags/tag_frame.asp")
|
854
896
|
frame = browser.frame_by(id: "C09C4E4404314AAEAE85928EAC109A93")
|
855
897
|
frame.body # => "<html><head></head><body></body></html>"
|
856
898
|
```
|
@@ -860,7 +902,7 @@ frame.body # => "<html><head></head><body></body></html>"
|
|
860
902
|
Returns current frame's doctype.
|
861
903
|
|
862
904
|
```ruby
|
863
|
-
browser.
|
905
|
+
browser.go_to("https://www.w3schools.com/tags/tag_frame.asp")
|
864
906
|
browser.main_frame.doctype # => "<!DOCTYPE html>"
|
865
907
|
```
|
866
908
|
|
@@ -871,7 +913,7 @@ Sets a content of a given frame.
|
|
871
913
|
* html `String`
|
872
914
|
|
873
915
|
```ruby
|
874
|
-
browser.
|
916
|
+
browser.go_to("https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe")
|
875
917
|
frame = browser.frames[1]
|
876
918
|
frame.body # <html lang="en"><head><style>body {transition: opacity ease-in 0.2s; }...
|
877
919
|
frame.set_content("<html><head></head><body><p>lol</p></body></html>")
|
@@ -900,7 +942,7 @@ browser.on(:dialog) do |dialog|
|
|
900
942
|
dialog.dismiss
|
901
943
|
end
|
902
944
|
end
|
903
|
-
browser.
|
945
|
+
browser.go_to("https://google.com")
|
904
946
|
```
|
905
947
|
|
906
948
|
|
@@ -917,13 +959,13 @@ context = browser.contexts.create
|
|
917
959
|
|
918
960
|
t1 = Thread.new(context) do |c|
|
919
961
|
page = c.create_page
|
920
|
-
page.
|
962
|
+
page.go_to("https://www.google.com/search?q=Ruby+headless+driver+for+Capybara")
|
921
963
|
page.screenshot(path: "t1.png")
|
922
964
|
end
|
923
965
|
|
924
966
|
t2 = Thread.new(context) do |c|
|
925
967
|
page = c.create_page
|
926
|
-
page.
|
968
|
+
page.go_to("https://www.google.com/search?q=Ruby+static+typing")
|
927
969
|
page.screenshot(path: "t2.png")
|
928
970
|
end
|
929
971
|
|
@@ -942,7 +984,7 @@ browser = Ferrum::Browser.new
|
|
942
984
|
t1 = Thread.new(browser) do |b|
|
943
985
|
context = b.contexts.create
|
944
986
|
page = context.create_page
|
945
|
-
page.
|
987
|
+
page.go_to("https://www.google.com/search?q=Ruby+headless+driver+for+Capybara")
|
946
988
|
page.screenshot(path: "t1.png")
|
947
989
|
context.dispose
|
948
990
|
end
|
@@ -950,7 +992,7 @@ end
|
|
950
992
|
t2 = Thread.new(browser) do |b|
|
951
993
|
context = b.contexts.create
|
952
994
|
page = context.create_page
|
953
|
-
page.
|
995
|
+
page.go_to("https://www.google.com/search?q=Ruby+static+typing")
|
954
996
|
page.screenshot(path: "t2.png")
|
955
997
|
context.dispose
|
956
998
|
end
|
@@ -961,26 +1003,20 @@ t2.join
|
|
961
1003
|
browser.quit
|
962
1004
|
```
|
963
1005
|
|
1006
|
+
## Development
|
1007
|
+
|
1008
|
+
After checking out the repo, run `bundle install` to install dependencies.
|
1009
|
+
|
1010
|
+
Then, run `bundle exec rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
1011
|
+
|
1012
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
1013
|
+
|
1014
|
+
|
1015
|
+
## Contributing
|
1016
|
+
|
1017
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/rubycdp/ferrum).
|
964
1018
|
|
965
1019
|
## License
|
966
1020
|
|
967
|
-
|
968
|
-
|
969
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
970
|
-
a copy of this software and associated documentation files (the
|
971
|
-
"Software"), to deal in the Software without restriction, including
|
972
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
973
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
974
|
-
permit persons to whom the Software is furnished to do so, subject to
|
975
|
-
the following conditions:
|
976
|
-
|
977
|
-
The above copyright notice and this permission notice shall be
|
978
|
-
included in all copies or substantial portions of the Software.
|
979
|
-
|
980
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
981
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
982
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
983
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
984
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
985
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
986
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1021
|
+
The gem is available as open source under the terms of the
|
1022
|
+
[MIT License](https://opensource.org/licenses/MIT).
|