File tree Expand file tree Collapse file tree 4 files changed +32
-2
lines changed
Expand file tree Collapse file tree 4 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -379,7 +379,11 @@ def dismiss_modal(type, options = {})
379379 private
380380
381381 def build_remote_debug_url ( path :)
382- "http://#{ browser . process . host } :#{ browser . process . port } #{ 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
383387 end
384388
385389 def default_domain
Original file line number Diff line number Diff line change @@ -1605,6 +1605,15 @@ 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
16081617 end
16091618 end
16101619end
Original file line number Diff line number Diff line change 3030 end
3131
3232 describe "debug_url" do
33- it "parses the devtools frontend url correctly" do
33+ it "parses the devtools frontend url correctly when devtoolsFrontendUrl is relative " do
3434 driver = described_class . new ( nil , { port : 12_345 } )
3535 driver . browser # initialize browser before stubbing Net::HTTP as it also calls it
3636 uri = instance_double ( URI )
4040
4141 expect ( driver . debug_url ) . to eq ( "http://127.0.0.1:12345/works" )
4242 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
4356 end
4457
4558 private
Original file line number Diff line number Diff line change 3030 Capybara ::Cuprite ::Driver . new ( app , options )
3131end
3232
33+ Capybara . register_driver ( :cuprite_with_inspector ) do |app |
34+ Capybara ::Cuprite ::Driver . new ( app , { inspector : true } )
35+ end
36+
3337module TestSessions
3438 Cuprite = Capybara ::Session . new ( :cuprite , TestApp )
3539end
You can’t perform that action at this time.
0 commit comments