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 = {})
379
379
private
380
380
381
381
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
383
387
end
384
388
385
389
def default_domain
Original file line number Diff line number Diff line change @@ -1605,6 +1605,15 @@ 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
1608
1617
end
1609
1618
end
1610
1619
end
Original file line number Diff line number Diff line change 30
30
end
31
31
32
32
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
34
34
driver = described_class . new ( nil , { port : 12_345 } )
35
35
driver . browser # initialize browser before stubbing Net::HTTP as it also calls it
36
36
uri = instance_double ( URI )
40
40
41
41
expect ( driver . debug_url ) . to eq ( "http://127.0.0.1:12345/works" )
42
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
43
56
end
44
57
45
58
private
Original file line number Diff line number Diff line change 30
30
Capybara ::Cuprite ::Driver . new ( app , options )
31
31
end
32
32
33
+ Capybara . register_driver ( :cuprite_with_inspector ) do |app |
34
+ Capybara ::Cuprite ::Driver . new ( app , { inspector : true } )
35
+ end
36
+
33
37
module TestSessions
34
38
Cuprite = Capybara ::Session . new ( :cuprite , TestApp )
35
39
end
You can’t perform that action at this time.
0 commit comments