2222async def test_should_fire (page : Page , server ):
2323 result = []
2424
25- def on_dialog (dialog : Dialog ):
25+ async def on_dialog (dialog : Dialog ):
2626 result .append (True )
2727 assert dialog .type == "alert"
2828 assert dialog .defaultValue == ""
2929 assert dialog .message == "yo"
30- asyncio . create_task ( dialog .accept () )
30+ await dialog .accept ()
3131
3232 page .on ("dialog" , on_dialog )
3333 await page .evaluate ("alert('yo')" )
@@ -37,12 +37,12 @@ def on_dialog(dialog: Dialog):
3737async def test_should_allow_accepting_prompts (page : Page , server ):
3838 result = []
3939
40- def on_dialog (dialog : Dialog ):
40+ async def on_dialog (dialog : Dialog ):
4141 result .append (True )
4242 assert dialog .type == "prompt"
4343 assert dialog .defaultValue == "yes."
4444 assert dialog .message == "question?"
45- asyncio . create_task ( dialog .accept ("answer!" ) )
45+ await dialog .accept ("answer!" )
4646
4747 page .on ("dialog" , on_dialog )
4848 assert await page .evaluate ("prompt('question?', 'yes.')" ) == "answer!"
@@ -52,9 +52,9 @@ def on_dialog(dialog: Dialog):
5252async def test_should_dismiss_the_prompt (page : Page , server ):
5353 result = []
5454
55- def on_dialog (dialog : Dialog ):
55+ async def on_dialog (dialog : Dialog ):
5656 result .append (True )
57- asyncio . create_task ( dialog .dismiss () )
57+ await dialog .dismiss ()
5858
5959 page .on ("dialog" , on_dialog )
6060 assert await page .evaluate ("prompt('question?')" ) is None
@@ -64,9 +64,9 @@ def on_dialog(dialog: Dialog):
6464async def test_should_accept_the_confirm_prompt (page : Page , server ):
6565 result = []
6666
67- def on_dialog (dialog : Dialog ):
67+ async def on_dialog (dialog : Dialog ):
6868 result .append (True )
69- asyncio . create_task ( dialog .accept () )
69+ await dialog .accept ()
7070
7171 page .on ("dialog" , on_dialog )
7272 assert await page .evaluate ("confirm('boolean?')" ) is True
@@ -76,9 +76,9 @@ def on_dialog(dialog: Dialog):
7676async def test_should_dismiss_the_confirm_prompt (page : Page , server ):
7777 result = []
7878
79- def on_dialog (dialog : Dialog ):
79+ async def on_dialog (dialog : Dialog ):
8080 result .append (True )
81- asyncio . create_task ( dialog .dismiss () )
81+ await dialog .dismiss ()
8282
8383 page .on ("dialog" , on_dialog )
8484 assert await page .evaluate ("confirm('boolean?')" ) is False
0 commit comments