Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 8b6ce5d

Browse files
committed
Add a alert dialog test
The test dismisses an alert dialogue box.
1 parent cbeaa81 commit 8b6ce5d

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

tests/frame_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tests
33
import (
44
"testing"
55

6+
"github.com/stretchr/testify/assert"
67
"github.com/stretchr/testify/require"
78
)
89

@@ -21,3 +22,41 @@ func TestFramePress(t *testing.T) {
2122

2223
require.Equal(t, "AbC", f.InputValue("#text1", nil))
2324
}
25+
26+
func TestFrameDismissDialogBox(t *testing.T) {
27+
28+
t.Parallel()
29+
30+
tests := []struct {
31+
name string
32+
}{
33+
{
34+
name: "alert",
35+
},
36+
}
37+
38+
for _, tt := range tests {
39+
t.Run(tt.name, func(t *testing.T) {
40+
t.Parallel()
41+
42+
b := newTestBrowser(t, withFileServer())
43+
44+
p := b.NewPage(nil)
45+
46+
err := b.await(func() error {
47+
opts := b.toGojaValue(struct {
48+
WaitUntil string `js:"waitUntil"`
49+
}{
50+
WaitUntil: "networkidle",
51+
})
52+
b.promise(p.Goto(b.staticURL("dialog.html?dialogType="+tt.name), opts)).then(func() {
53+
result := p.TextContent("#text", nil)
54+
assert.EqualValues(t, "Hello World", result)
55+
})
56+
57+
return nil
58+
})
59+
require.NoError(t, err)
60+
})
61+
}
62+
}

tests/static/dialog.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<html lang="en">
2+
<head>
3+
<script>
4+
const queryString = window.location.search;
5+
const urlParams = new URLSearchParams(queryString);
6+
const dialogType = urlParams.get('dialogType')
7+
8+
switch(dialogType) {
9+
case "alert":
10+
alert("Click accept");
11+
break;
12+
}
13+
</script>
14+
</head>
15+
<body>
16+
<div id='text'>Hello World</div>
17+
</body>
18+
</html>

0 commit comments

Comments
 (0)