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

Commit 94271d2

Browse files
committed
Refactor the tests to assert a change
Instead of always checking that the text field is Hello World, when a dialog box opens, it will change the textField to reflect which type of dialog appeared.
1 parent e5f961d commit 94271d2

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

tests/frame_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ func TestFrameDismissDialogBox(t *testing.T) {
5656
WaitUntil: "networkidle",
5757
})
5858
b.promise(p.Goto(b.staticURL("dialog.html?dialogType="+tt.name), opts)).then(func() {
59-
result := p.TextContent("#text", nil)
60-
assert.EqualValues(t, "Hello World", result)
59+
result := p.TextContent("#textField", nil)
60+
assert.EqualValues(t, tt.name+" dismissed", result)
6161
})
6262

6363
return nil

tests/static/dialog.html

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
<html lang="en">
2-
<head>
2+
<head></head>
3+
<body>
4+
<div id='textField'>Hello World</div>
5+
<br />
6+
<a href="/">click here</a>
7+
38
<script>
49
const queryString = window.location.search;
510
const urlParams = new URLSearchParams(queryString);
6-
const dialogType = urlParams.get('dialogType')
11+
const dialogType = urlParams.get('dialogType');
12+
const div = document.getElementById('textField');
713

814
switch(dialogType) {
915
case "alert":
1016
alert("Click accept");
17+
div.textContent = 'alert dismissed';
1118
break;
1219
case "confirm":
13-
confirm("Click accept")
20+
confirm("Click accept");
21+
div.textContent = 'confirm dismissed';
22+
break;
1423
case "prompt":
15-
prompt("Add text and then click accept")
24+
prompt("Add text and then click accept");
25+
div.textContent = 'prompt dismissed';
26+
break;
1627
}
1728
</script>
18-
</head>
19-
<body>
20-
<div id='text'>Hello World</div>
2129
</body>
2230
</html>

0 commit comments

Comments
 (0)