22
22
async def test_should_fire (page : Page , server ):
23
23
result = []
24
24
25
- def on_dialog (dialog : Dialog ):
25
+ async def on_dialog (dialog : Dialog ):
26
26
result .append (True )
27
27
assert dialog .type == "alert"
28
28
assert dialog .defaultValue == ""
29
29
assert dialog .message == "yo"
30
- asyncio . create_task ( dialog .accept () )
30
+ await dialog .accept ()
31
31
32
32
page .on ("dialog" , on_dialog )
33
33
await page .evaluate ("alert('yo')" )
@@ -37,12 +37,12 @@ def on_dialog(dialog: Dialog):
37
37
async def test_should_allow_accepting_prompts (page : Page , server ):
38
38
result = []
39
39
40
- def on_dialog (dialog : Dialog ):
40
+ async def on_dialog (dialog : Dialog ):
41
41
result .append (True )
42
42
assert dialog .type == "prompt"
43
43
assert dialog .defaultValue == "yes."
44
44
assert dialog .message == "question?"
45
- asyncio . create_task ( dialog .accept ("answer!" ) )
45
+ await dialog .accept ("answer!" )
46
46
47
47
page .on ("dialog" , on_dialog )
48
48
assert await page .evaluate ("prompt('question?', 'yes.')" ) == "answer!"
@@ -52,9 +52,9 @@ def on_dialog(dialog: Dialog):
52
52
async def test_should_dismiss_the_prompt (page : Page , server ):
53
53
result = []
54
54
55
- def on_dialog (dialog : Dialog ):
55
+ async def on_dialog (dialog : Dialog ):
56
56
result .append (True )
57
- asyncio . create_task ( dialog .dismiss () )
57
+ await dialog .dismiss ()
58
58
59
59
page .on ("dialog" , on_dialog )
60
60
assert await page .evaluate ("prompt('question?')" ) is None
@@ -64,9 +64,9 @@ def on_dialog(dialog: Dialog):
64
64
async def test_should_accept_the_confirm_prompt (page : Page , server ):
65
65
result = []
66
66
67
- def on_dialog (dialog : Dialog ):
67
+ async def on_dialog (dialog : Dialog ):
68
68
result .append (True )
69
- asyncio . create_task ( dialog .accept () )
69
+ await dialog .accept ()
70
70
71
71
page .on ("dialog" , on_dialog )
72
72
assert await page .evaluate ("confirm('boolean?')" ) is True
@@ -76,9 +76,9 @@ def on_dialog(dialog: Dialog):
76
76
async def test_should_dismiss_the_confirm_prompt (page : Page , server ):
77
77
result = []
78
78
79
- def on_dialog (dialog : Dialog ):
79
+ async def on_dialog (dialog : Dialog ):
80
80
result .append (True )
81
- asyncio . create_task ( dialog .dismiss () )
81
+ await dialog .dismiss ()
82
82
83
83
page .on ("dialog" , on_dialog )
84
84
assert await page .evaluate ("confirm('boolean?')" ) is False
0 commit comments