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 33### Added
44
55### Changed
6+ - ` :inspector ` option is retired
67
78### Fixed
9+ - Correctly open devtools page when calling ` debug ` [ #296 , #297 ]
810
911### Removed
1012
1416### Added
1517
1618### Changed
17-
1819- ` wait_for_network_idle ` doesn't raise error, instead simply returns ` nil `
1920
2021### Fixed
21-
2222- Assigning broken unicode to a node directly from JS can lead to ` JSON::ParserError: incomplete surrogate pair at ... ` error
2323
2424### Removed
2727## [ 0.15.1] ( https://github.com/rubycdp/ferrum/compare/v0.15...0.15.1 ) - (Jun 15, 2024) ##
2828
2929### Added
30-
3130- Support for ` Driver#send_keys ` , the ` :focused ` filter, and ` Driver#active_element ` [ #261 ]
3231
3332### Changed
Original file line number Diff line number Diff line change 6767
6868## Debugging
6969
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.
8272
8373``` ruby
8474it " does something useful" do
Original file line number Diff line number Diff line change @@ -25,5 +25,5 @@ Gem::Specification.new do |s|
2525 s . required_ruby_version = ">= 2.7.0"
2626
2727 s . add_dependency "capybara" , "~> 3.0"
28- s . add_dependency "ferrum" , "~> 0.16 .0"
28+ s . add_dependency "ferrum" , "~> 0.17 .0"
2929end
Original file line number Diff line number Diff line change @@ -274,32 +274,8 @@ def basic_authorize(user, password)
274274 end
275275 alias authorize basic_authorize
276276
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 ( ...)
303279 end
304280
305281 def pause
@@ -378,14 +354,6 @@ def dismiss_modal(type, options = {})
378354
379355 private
380356
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-
389357 def default_domain
390358 if @started
391359 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)
16051605
16061606 expect ( @session ) . to have_content ( "test_cookie" )
16071607 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
16171608 end
16181609 end
16191610end
Original file line number Diff line number Diff line change 2929 end
3030 end
3131
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-
5832 private
5933
6034 def with_capybara_save_path ( path )
Original file line number Diff line number Diff line change 2424
2525Capybara . register_driver ( :cuprite ) do |app |
2626 options = { }
27- options . merge! ( inspector : true ) if ENV [ "INSPECTOR" ]
2827 options . merge! ( logger : StringIO . new ) if ENV [ "CI" ]
2928 options . merge! ( headless : false ) if ENV [ "HEADLESS" ] == "false"
3029 Capybara ::Cuprite ::Driver . new ( app , options )
3130end
3231
33- Capybara . register_driver ( :cuprite_with_inspector ) do |app |
34- Capybara ::Cuprite ::Driver . new ( app , { inspector : true } )
35- end
36-
3732module TestSessions
3833 Cuprite = Capybara ::Session . new ( :cuprite , TestApp )
3934end
You can’t perform that action at this time.
0 commit comments