@@ -47,7 +47,7 @@ class BiDi
47
47
expect ( driver . window_handles ) . to include ( id )
48
48
end
49
49
50
- it 'errors on unknown type' do
50
+ it 'errors on unknown type' , except : { browser : :firefox , reason : "Doesn't return the expected error" } do
51
51
msg = /invalid argument: Invalid enum value. Expected 'tab' | 'window', received 'unknown'/
52
52
expect {
53
53
described_class . new ( bridge ) . create ( type : :unknown )
@@ -75,41 +75,52 @@ class BiDi
75
75
end
76
76
77
77
it 'sets the viewport' do
78
- browsing_context = described_class . new ( driver )
78
+ browsing_context = described_class . new ( bridge )
79
79
browsing_context . set_viewport ( width : 800 , height : 600 , device_pixel_ratio : 2.0 )
80
80
expect ( driver . execute_script ( 'return [window.innerWidth, window.innerHeight]' ) ) . to eq ( [ 800 , 600 ] )
81
81
expect ( driver . execute_script ( 'return window.devicePixelRatio' ) ) . to eq ( 2.0 )
82
82
end
83
83
84
84
it 'accepts users prompts without text' do
85
- browsing_context = described_class . new ( driver )
86
- window = browsing_context . create
85
+ browsing_context = described_class . new ( bridge )
87
86
87
+ driver . navigate . to url_for ( 'alerts.html' )
88
+ driver . find_element ( id : 'alert' ) . click
89
+ wait . until { driver . switch_to . alert }
90
+ window = driver . window_handles . first
88
91
browsing_context . handle_user_prompt ( window , accept : true )
92
+ wait_for_no_alert
89
93
90
- expect ( driver . page_source ) . to include ( 'hello ')
94
+ expect ( driver . title ) . to eq ( 'Testing Alerts ')
91
95
end
92
96
93
97
it 'accepts users prompts with text' do
94
- browsing_context = described_class . new ( driver )
95
- window = browsing_context . create
96
-
98
+ browsing_context = described_class . new ( bridge )
99
+ driver . navigate . to url_for ( 'alerts.html' )
100
+ driver . find_element ( id : 'prompt' ) . click
101
+ wait_for_alert
102
+ window = driver . window_handles . first
97
103
browsing_context . handle_user_prompt ( window , accept : true , text : 'Hello, world!' )
104
+ wait_for_no_alert
98
105
99
- expect ( driver . page_source ) . to include ( 'hello ')
106
+ expect ( driver . title ) . to eq ( 'Testing Alerts ')
100
107
end
101
108
102
109
it 'rejects users prompts' do
103
- browsing_context = described_class . new ( driver )
104
- window = browsing_context . create
110
+ browsing_context = described_class . new ( bridge )
111
+ driver . navigate . to url_for ( 'alerts.html' )
112
+ driver . find_element ( id : 'alert' ) . click
113
+ wait_for_alert
114
+ window = driver . window_handles . first
105
115
106
116
browsing_context . handle_user_prompt ( window , accept : false )
117
+ wait_for_no_alert
107
118
108
- expect ( driver . page_source ) . to include ( 'goodbye ')
119
+ expect ( driver . title ) . to eq ( 'Testing Alerts ')
109
120
end
110
121
111
122
it 'activates a browser context' do
112
- browsing_context = described_class . new ( driver )
123
+ browsing_context = described_class . new ( bridge )
113
124
browsing_context . create
114
125
115
126
expect ( driver . execute_script ( 'return document.hasFocus();' ) ) . to be_falsey
0 commit comments