File tree Expand file tree Collapse file tree 7 files changed +7
-90
lines changed Expand file tree Collapse file tree 7 files changed +7
-90
lines changed Original file line number Diff line number Diff line change 3
3
### Added
4
4
5
5
### Changed
6
+ - ` :inspector ` option is retired
6
7
7
8
### Fixed
9
+ - Correctly open devtools page when calling ` debug ` [ #296 , #297 ]
8
10
9
11
### Removed
10
12
14
16
### Added
15
17
16
18
### Changed
17
-
18
19
- ` wait_for_network_idle ` doesn't raise error, instead simply returns ` nil `
19
20
20
21
### Fixed
21
-
22
22
- Assigning broken unicode to a node directly from JS can lead to ` JSON::ParserError: incomplete surrogate pair at ... ` error
23
23
24
24
### Removed
27
27
## [ 0.15.1] ( https://github.com/rubycdp/ferrum/compare/v0.15...0.15.1 ) - (Jun 15, 2024) ##
28
28
29
29
### Added
30
-
31
30
- Support for ` Driver#send_keys ` , the ` :focused ` filter, and ` Driver#active_element ` [ #261 ]
32
31
33
32
### Changed
Original file line number Diff line number Diff line change 67
67
68
68
## Debugging
69
69
70
- If you pass ` inspector ` option, remote debugging will be enabled if you run
71
- tests with ` INSPECTOR=true ` . Then you can put ` page.driver.debug ` or
72
- ` page.driver.debug(binding) ` in your test to pause it. This will launch the
73
- browser where you can inspect the content.
74
-
75
- ``` ruby
76
- Capybara .register_driver :cuprite do |app |
77
- Capybara ::Cuprite ::Driver .new (app, inspector: ENV [' INSPECTOR' ])
78
- end
79
- ```
80
-
81
- then somewhere in the test:
70
+ You can put ` page.driver.debug ` or ` page.driver.debug(binding) ` in your test to pause it.
71
+ This will launch the browser where you can inspect the content.
82
72
83
73
``` ruby
84
74
it " does something useful" do
Original file line number Diff line number Diff line change @@ -25,5 +25,5 @@ Gem::Specification.new do |s|
25
25
s . required_ruby_version = ">= 2.7.0"
26
26
27
27
s . add_dependency "capybara" , "~> 3.0"
28
- s . add_dependency "ferrum" , "~> 0.16 .0"
28
+ s . add_dependency "ferrum" , "~> 0.17 .0"
29
29
end
Original file line number Diff line number Diff line change @@ -274,32 +274,8 @@ def basic_authorize(user, password)
274
274
end
275
275
alias authorize basic_authorize
276
276
277
- def debug_url
278
- response = JSON . parse ( Net ::HTTP . get ( URI ( build_remote_debug_url ( path : "/json" ) ) ) )
279
-
280
- devtools_frontend_path = response [ 0 ] &.[]( "devtoolsFrontendUrl" )
281
- raise "Could not generate debug url for remote debugging session" unless devtools_frontend_path
282
-
283
- build_remote_debug_url ( path : devtools_frontend_path )
284
- end
285
-
286
- def debug ( binding = nil )
287
- if @options [ :inspector ]
288
- Process . spawn ( browser . process . path , debug_url )
289
-
290
- if binding . respond_to? ( :pry )
291
- Pry . start ( binding )
292
- elsif binding . respond_to? ( :irb )
293
- binding . irb
294
- else
295
- pause
296
- end
297
- else
298
- raise Error , "To use the remote debugging, you have to launch " \
299
- "the driver with `inspector: ENV['INSPECTOR']` " \
300
- "configuration option and run your test suite passing " \
301
- "env variable"
302
- end
277
+ def debug ( ...)
278
+ browser . debug ( ...)
303
279
end
304
280
305
281
def pause
@@ -378,14 +354,6 @@ def dismiss_modal(type, options = {})
378
354
379
355
private
380
356
381
- def build_remote_debug_url ( path :)
382
- uri = URI . parse ( path )
383
- uri . scheme ||= "http"
384
- uri . host ||= browser . process . host
385
- uri . port ||= browser . process . port
386
- uri . to_s
387
- end
388
-
389
357
def default_domain
390
358
if @started
391
359
URI . parse ( browser . current_url ) . host
Original file line number Diff line number Diff line change @@ -1605,15 +1605,6 @@ def create_screenshot(file, *args)
1605
1605
1606
1606
expect ( @session ) . to have_content ( "test_cookie" )
1607
1607
end
1608
-
1609
- it "has a working debug_url" do
1610
- session = Capybara ::Session . new ( :cuprite_with_inspector , TestApp )
1611
- session . visit "/cuprite/arbitrary_path/200"
1612
-
1613
- expect do
1614
- URI . parse ( session . driver . debug_url )
1615
- end . not_to raise_error
1616
- end
1617
1608
end
1618
1609
end
1619
1610
end
Original file line number Diff line number Diff line change 29
29
end
30
30
end
31
31
32
- describe "debug_url" do
33
- it "parses the devtools frontend url correctly when devtoolsFrontendUrl is relative" do
34
- driver = described_class . new ( nil , { port : 12_345 } )
35
- driver . browser # initialize browser before stubbing Net::HTTP as it also calls it
36
- uri = instance_double ( URI )
37
-
38
- allow ( driver ) . to receive ( :URI ) . with ( "http://127.0.0.1:12345/json" ) . and_return ( uri )
39
- allow ( Net ::HTTP ) . to receive ( :get ) . with ( uri ) . and_return ( %([{"devtoolsFrontendUrl":"/works"}]) )
40
-
41
- expect ( driver . debug_url ) . to eq ( "http://127.0.0.1:12345/works" )
42
- end
43
-
44
- it "parses the devtools frontend url correctly when devtoolsFrontendUrl is fully qualified" do
45
- driver = described_class . new ( nil , { port : 12_346 } )
46
- driver . browser # initialize browser before stubbing Net::HTTP as it also calls it
47
- uri = instance_double ( URI )
48
-
49
- allow ( driver ) . to receive ( :URI ) . with ( "http://127.0.0.1:12346/json" ) . and_return ( uri )
50
- allow ( Net ::HTTP ) . to receive ( :get ) . with ( uri ) . and_return (
51
- %([{"devtoolsFrontendUrl":"https://chrome-devtools-frontend.appspot.com/serve_rev?ws=123"}])
52
- )
53
-
54
- expect ( driver . debug_url ) . to eq ( "https://chrome-devtools-frontend.appspot.com/serve_rev?ws=123" )
55
- end
56
- end
57
-
58
32
private
59
33
60
34
def with_capybara_save_path ( path )
Original file line number Diff line number Diff line change 24
24
25
25
Capybara . register_driver ( :cuprite ) do |app |
26
26
options = { }
27
- options . merge! ( inspector : true ) if ENV [ "INSPECTOR" ]
28
27
options . merge! ( logger : StringIO . new ) if ENV [ "CI" ]
29
28
options . merge! ( headless : false ) if ENV [ "HEADLESS" ] == "false"
30
29
Capybara ::Cuprite ::Driver . new ( app , options )
31
30
end
32
31
33
- Capybara . register_driver ( :cuprite_with_inspector ) do |app |
34
- Capybara ::Cuprite ::Driver . new ( app , { inspector : true } )
35
- end
36
-
37
32
module TestSessions
38
33
Cuprite = Capybara ::Session . new ( :cuprite , TestApp )
39
34
end
You can’t perform that action at this time.
0 commit comments