/** @type {import('nightwatch').NightwatchTest} */
'scroll behavior': function (browser) {
- const TIMEOUT = 2000
+ const TIMEOUT = 3000
browser
.url('http://localhost:8080/scroll-behavior/')
.execute(function () {
window.scrollTo(0, 100)
+ // works in Safari
+ document.querySelector('li:nth-child(2) a').click()
})
- .click('li:nth-child(2) a')
+ // .click('li:nth-child(2) a')
.waitForElementPresent('.view.foo', TIMEOUT)
.assert.containsText('.view', 'foo')
.execute(function () {
'restore scroll position on back again'
)
- .click('li:nth-child(3) a')
+ .execute(function () {
+ // for Safari...
+ document.querySelector('li:nth-child(3) a').click()
+ })
.waitForElementPresent('.view.bar', TIMEOUT)
.assert.evaluate(
function () {
.waitForElementPresent('.view.foo', TIMEOUT)
.execute(function () {
window.scrollTo(0, 150)
+ // revisiting the same hash should scroll again
+ document.querySelector('li:nth-child(4) a').click()
})
- // revisiting the same hash should scroll again
- .click('li:nth-child(4) a')
.waitForElementPresent('.view.bar', TIMEOUT)
.execute(function () {
window.scrollTo(0, 50)
+ document.querySelector('li:nth-child(4) a').click()
})
- .click('li:nth-child(4) a')
.assert.evaluate(
function () {
return (
)
// going to an anchor entry, scrolling, then back then forward restores the position
- .click('li:nth-child(4) a')
+ .execute(function () {
+ document.querySelector('li:nth-child(4) a').click()
+ })
.waitForElementPresent('.view.bar', TIMEOUT)
// at this point we scrolled to the anchor, scroll again somewhere else
// and then go back
)
// going again to a popped entry should not restore the saved position
- .click('li:nth-child(1) a')
+ .execute(function () {
+ document.querySelector('li:nth-child(1) a').click()
+ })
.waitForElementPresent('.view.home', TIMEOUT)
.click('li:nth-child(4) a')
.waitForElementPresent('.view.bar', TIMEOUT)