@@ -142,6 +142,11 @@ describe('execute_script', () => {
142142 assert . deepEqual ( parsed , { a : 1 , b : 2 } ) ;
143143 } ) ;
144144
145+ it ( 'executes script with arguments' , async ( ) => {
146+ const result = await client . callTool ( 'execute_script' , { script : 'return arguments[0] + arguments[1];' , args : [ 10 , 32 ] } ) ;
147+ assert . equal ( getResponseText ( result ) , '42' ) ;
148+ } ) ;
149+
145150 it ( 'returns error for invalid script' , async ( ) => {
146151 const result = await client . callTool ( 'execute_script' , { script : 'return undefinedVariable.property;' } ) ;
147152 assert . equal ( result . isError , true ) ;
@@ -266,7 +271,7 @@ describe('frame management', () => {
266271 } ) ;
267272
268273 it ( 'switch_to_frame by index' , async ( ) => {
269- let result = await client . callTool ( 'switch_to_frame' , { by : ' index' , value : '0' } ) ;
274+ let result = await client . callTool ( 'switch_to_frame' , { index : 0 } ) ;
270275 assert . equal ( getResponseText ( result ) , 'Switched to frame' ) ;
271276
272277 result = await client . callTool ( 'get_element_text' , { by : 'id' , value : 'frame-text' } ) ;
@@ -276,8 +281,8 @@ describe('frame management', () => {
276281 await client . callTool ( 'switch_to_default_content' ) ;
277282 } ) ;
278283
279- it ( 'switch_to_frame returns error for invalid index' , async ( ) => {
280- const result = await client . callTool ( 'switch_to_frame' , { by : 'index' , value : 'abc' } ) ;
284+ it ( 'switch_to_frame returns error when no locator or index provided ' , async ( ) => {
285+ const result = await client . callTool ( 'switch_to_frame' , { } ) ;
281286 assert . equal ( result . isError , true ) ;
282287 } ) ;
283288} ) ;
@@ -299,14 +304,18 @@ describe('alert handling', () => {
299304 await client . stop ( ) ;
300305 } ) ;
301306
302- it ( 'get_alert_text reads alert message' , async ( ) => {
307+ it ( 'get_alert_text reads alert message and accept_alert closes it ' , async ( ) => {
303308 await client . callTool ( 'click_element' , { by : 'id' , value : 'alert-btn' } ) ;
304309 const result = await client . callTool ( 'get_alert_text' ) ;
305310 assert . equal ( getResponseText ( result ) , 'Hello from alert!' ) ;
311+
312+ // Accept the alert to close it
313+ const acceptResult = await client . callTool ( 'accept_alert' ) ;
314+ assert . equal ( getResponseText ( acceptResult ) , 'Alert accepted' ) ;
306315 } ) ;
307316
308- it ( 'accept_alert dismisses the alert' , async ( ) => {
309- // Alert is still open from previous test
317+ it ( 'accept_alert accepts a fresh alert' , async ( ) => {
318+ await client . callTool ( 'click_element' , { by : 'id' , value : 'alert-btn' } ) ;
310319 const result = await client . callTool ( 'accept_alert' ) ;
311320 assert . equal ( getResponseText ( result ) , 'Alert accepted' ) ;
312321 } ) ;
0 commit comments