Skip to content

Commit 40cbc49

Browse files
committed
test(e2e): fix in safari
1 parent 0078147 commit 40cbc49

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

e2e/specs/scroll-behavior.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77

88
/** @type {import('nightwatch').NightwatchTest} */
99
'scroll behavior': function (browser) {
10-
const TIMEOUT = 2000
10+
const TIMEOUT = 3000
1111

1212
browser
1313
.url('http://localhost:8080/scroll-behavior/')
@@ -17,8 +17,10 @@ module.exports = {
1717

1818
.execute(function () {
1919
window.scrollTo(0, 100)
20+
// works in Safari
21+
document.querySelector('li:nth-child(2) a').click()
2022
})
21-
.click('li:nth-child(2) a')
23+
// .click('li:nth-child(2) a')
2224
.waitForElementPresent('.view.foo', TIMEOUT)
2325
.assert.containsText('.view', 'foo')
2426
.execute(function () {
@@ -63,7 +65,10 @@ module.exports = {
6365
'restore scroll position on back again'
6466
)
6567

66-
.click('li:nth-child(3) a')
68+
.execute(function () {
69+
// for Safari...
70+
document.querySelector('li:nth-child(3) a').click()
71+
})
6772
.waitForElementPresent('.view.bar', TIMEOUT)
6873
.assert.evaluate(
6974
function () {
@@ -112,14 +117,14 @@ module.exports = {
112117
.waitForElementPresent('.view.foo', TIMEOUT)
113118
.execute(function () {
114119
window.scrollTo(0, 150)
120+
// revisiting the same hash should scroll again
121+
document.querySelector('li:nth-child(4) a').click()
115122
})
116-
// revisiting the same hash should scroll again
117-
.click('li:nth-child(4) a')
118123
.waitForElementPresent('.view.bar', TIMEOUT)
119124
.execute(function () {
120125
window.scrollTo(0, 50)
126+
document.querySelector('li:nth-child(4) a').click()
121127
})
122-
.click('li:nth-child(4) a')
123128
.assert.evaluate(
124129
function () {
125130
return (
@@ -151,7 +156,9 @@ module.exports = {
151156
)
152157

153158
// going to an anchor entry, scrolling, then back then forward restores the position
154-
.click('li:nth-child(4) a')
159+
.execute(function () {
160+
document.querySelector('li:nth-child(4) a').click()
161+
})
155162
.waitForElementPresent('.view.bar', TIMEOUT)
156163
// at this point we scrolled to the anchor, scroll again somewhere else
157164
// and then go back
@@ -173,7 +180,9 @@ module.exports = {
173180
)
174181

175182
// going again to a popped entry should not restore the saved position
176-
.click('li:nth-child(1) a')
183+
.execute(function () {
184+
document.querySelector('li:nth-child(1) a').click()
185+
})
177186
.waitForElementPresent('.view.home', TIMEOUT)
178187
.click('li:nth-child(4) a')
179188
.waitForElementPresent('.view.bar', TIMEOUT)

0 commit comments

Comments
 (0)