@@ -47,7 +47,7 @@ class BiDi
4747            expect ( driver . window_handles ) . to  include ( id ) 
4848          end 
4949
50-           it  'errors on unknown type'  do 
50+           it  'errors on unknown type' ,   except :  { browser :  :firefox ,   reason :  "Doesn't return the expected error" }  do 
5151            msg  =  /invalid argument: Invalid enum value. Expected 'tab' | 'window', received 'unknown'/ 
5252            expect  { 
5353              described_class . new ( bridge ) . create ( type : :unknown ) 
@@ -75,41 +75,52 @@ class BiDi
7575        end 
7676
7777        it  'sets the viewport'  do 
78-           browsing_context  =  described_class . new ( driver ) 
78+           browsing_context  =  described_class . new ( bridge ) 
7979          browsing_context . set_viewport ( width : 800 ,  height : 600 ,  device_pixel_ratio : 2.0 ) 
8080          expect ( driver . execute_script ( 'return [window.innerWidth, window.innerHeight]' ) ) . to  eq ( [ 800 ,  600 ] ) 
8181          expect ( driver . execute_script ( 'return window.devicePixelRatio' ) ) . to  eq ( 2.0 ) 
8282        end 
8383
8484        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 ) 
8786
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 
8891          browsing_context . handle_user_prompt ( window ,  accept : true ) 
92+           wait_for_no_alert 
8993
90-           expect ( driver . page_source ) . to  include ( 'hello ') 
94+           expect ( driver . title ) . to  eq ( 'Testing Alerts ') 
9195        end 
9296
9397        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 
97103          browsing_context . handle_user_prompt ( window ,  accept : true ,  text : 'Hello, world!' ) 
104+           wait_for_no_alert 
98105
99-           expect ( driver . page_source ) . to  include ( 'hello ') 
106+           expect ( driver . title ) . to  eq ( 'Testing Alerts ') 
100107        end 
101108
102109        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 
105115
106116          browsing_context . handle_user_prompt ( window ,  accept : false ) 
117+           wait_for_no_alert 
107118
108-           expect ( driver . page_source ) . to  include ( 'goodbye ') 
119+           expect ( driver . title ) . to  eq ( 'Testing Alerts ') 
109120        end 
110121
111122        it  'activates a browser context'  do 
112-           browsing_context  =  described_class . new ( driver ) 
123+           browsing_context  =  described_class . new ( bridge ) 
113124          browsing_context . create 
114125
115126          expect ( driver . execute_script ( 'return document.hasFocus();' ) ) . to  be_falsey 
0 commit comments