@@ -7,7 +7,7 @@ module.exports = {
7
7
8
8
/** @type {import('nightwatch').NightwatchTest } */
9
9
'scroll behavior' : function ( browser ) {
10
- const TIMEOUT = 2000
10
+ const TIMEOUT = 3000
11
11
12
12
browser
13
13
. url ( 'http://localhost:8080/scroll-behavior/' )
@@ -17,8 +17,10 @@ module.exports = {
17
17
18
18
. execute ( function ( ) {
19
19
window . scrollTo ( 0 , 100 )
20
+ // works in Safari
21
+ document . querySelector ( 'li:nth-child(2) a' ) . click ( )
20
22
} )
21
- . click ( 'li:nth-child(2) a' )
23
+ // .click('li:nth-child(2) a')
22
24
. waitForElementPresent ( '.view.foo' , TIMEOUT )
23
25
. assert . containsText ( '.view' , 'foo' )
24
26
. execute ( function ( ) {
@@ -63,7 +65,10 @@ module.exports = {
63
65
'restore scroll position on back again'
64
66
)
65
67
66
- . click ( 'li:nth-child(3) a' )
68
+ . execute ( function ( ) {
69
+ // for Safari...
70
+ document . querySelector ( 'li:nth-child(3) a' ) . click ( )
71
+ } )
67
72
. waitForElementPresent ( '.view.bar' , TIMEOUT )
68
73
. assert . evaluate (
69
74
function ( ) {
@@ -112,14 +117,14 @@ module.exports = {
112
117
. waitForElementPresent ( '.view.foo' , TIMEOUT )
113
118
. execute ( function ( ) {
114
119
window . scrollTo ( 0 , 150 )
120
+ // revisiting the same hash should scroll again
121
+ document . querySelector ( 'li:nth-child(4) a' ) . click ( )
115
122
} )
116
- // revisiting the same hash should scroll again
117
- . click ( 'li:nth-child(4) a' )
118
123
. waitForElementPresent ( '.view.bar' , TIMEOUT )
119
124
. execute ( function ( ) {
120
125
window . scrollTo ( 0 , 50 )
126
+ document . querySelector ( 'li:nth-child(4) a' ) . click ( )
121
127
} )
122
- . click ( 'li:nth-child(4) a' )
123
128
. assert . evaluate (
124
129
function ( ) {
125
130
return (
@@ -151,7 +156,9 @@ module.exports = {
151
156
)
152
157
153
158
// 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
+ } )
155
162
. waitForElementPresent ( '.view.bar' , TIMEOUT )
156
163
// at this point we scrolled to the anchor, scroll again somewhere else
157
164
// and then go back
@@ -173,7 +180,9 @@ module.exports = {
173
180
)
174
181
175
182
// 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
+ } )
177
186
. waitForElementPresent ( '.view.home' , TIMEOUT )
178
187
. click ( 'li:nth-child(4) a' )
179
188
. waitForElementPresent ( '.view.bar' , TIMEOUT )
0 commit comments