@@ -58,7 +58,11 @@ suite(function (env) {
5858 assert . strictEqual ( await box . getAttribute ( 'class' ) , '' )
5959
6060 await driver . actions ( ) . click ( box ) . perform ( )
61- assert . strictEqual ( await box . getAttribute ( 'class' ) , 'green' )
61+ await driver . wait (
62+ async ( ) => {
63+ assert . strictEqual ( await box . getAttribute ( 'class' ) , 'green' )
64+ return true
65+ } , 10000 )
6266 } )
6367
6468 it ( 'click(element) clicks in center of element' , async function ( ) {
@@ -70,8 +74,12 @@ suite(function (env) {
7074
7175 await driver . actions ( ) . click ( div ) . perform ( )
7276
73- const clicks = await driver . executeScript ( 'return clicks' )
74- assert . deepStrictEqual ( clicks , [ [ 250 , 250 ] ] )
77+ await driver . wait (
78+ async ( ) => {
79+ const clicks = await driver . executeScript ( 'return clicks' )
80+ assert . deepStrictEqual ( clicks , [ [ 250 , 250 ] ] )
81+ return true
82+ } , 10000 )
7583 } )
7684
7785 it ( 'can move relative to element center' , async function ( ) {
@@ -87,8 +95,12 @@ suite(function (env) {
8795 . click ( )
8896 . perform ( )
8997
90- const clicks = await driver . executeScript ( 'return clicks' )
91- assert . deepStrictEqual ( clicks , [ [ 260 , 260 ] ] )
98+ await driver . wait (
99+ async ( ) => {
100+ const clicks = await driver . executeScript ( 'return clicks' )
101+ assert . deepStrictEqual ( clicks , [ [ 260 , 260 ] ] )
102+ return true
103+ } , 10000 )
92104 } )
93105
94106 ignore ( env . browsers ( Browser . SAFARI ) )
@@ -100,8 +112,10 @@ suite(function (env) {
100112
101113 await driver . actions ( ) . doubleClick ( box ) . perform ( )
102114 await driver . wait (
103- async ( ) => await box . getAttribute ( 'class' ) === 'blue' , 5000 )
104- assert . strictEqual ( await box . getAttribute ( 'class' ) , 'blue' )
115+ async ( ) => {
116+ assert . strictEqual ( await box . getAttribute ( 'class' ) , 'blue' )
117+ return true
118+ } , 10000 )
105119 } )
106120
107121 // For some reason for Chrome 75 we need to wrap this test in an extra
@@ -143,10 +157,13 @@ suite(function (env) {
143157 . move ( { x : 100 , y : 100 , origin : Origin . POINTER } )
144158 . release ( )
145159 . perform ( )
160+
146161 await driver . wait (
147- async ( ) => await slide . getCssValue ( 'left' ) === '101px' , 5000 )
148- assert . strictEqual ( await slide . getCssValue ( 'left' ) , '101px' )
149- assert . strictEqual ( await slide . getCssValue ( 'top' ) , '101px' )
162+ async ( ) => {
163+ assert . strictEqual ( await slide . getCssValue ( 'left' ) , '101px' )
164+ assert . strictEqual ( await slide . getCssValue ( 'left' ) , '101px' )
165+ return true
166+ } , 10000 )
150167 } )
151168
152169 it ( 'can move to and click element in an iframe' , async function ( ) {
@@ -160,7 +177,7 @@ suite(function (env) {
160177
161178 await driver . actions ( ) . click ( link ) . perform ( )
162179 await driver . switchTo ( ) . defaultContent ( )
163- return driver . wait ( until . titleIs ( 'Submitted Successfully!' ) , 5000 )
180+ return driver . wait ( until . titleIs ( 'Submitted Successfully!' ) , 10000 )
164181 } )
165182
166183 it ( 'can send keys to focused element' , async function ( ) {
@@ -174,8 +191,10 @@ suite(function (env) {
174191 await driver . actions ( ) . sendKeys ( 'foobar' ) . perform ( )
175192
176193 await driver . wait (
177- async ( ) => await el . getAttribute ( 'value' ) === 'foobar' , 5000 )
178- assert . strictEqual ( await el . getAttribute ( 'value' ) , 'foobar' )
194+ async ( ) => {
195+ assert . strictEqual ( await el . getAttribute ( 'value' ) , 'foobar' )
196+ return true
197+ } , 10000 )
179198 } )
180199
181200 it ( 'can get the property of element' , async function ( ) {
@@ -188,7 +207,11 @@ suite(function (env) {
188207
189208 await driver . actions ( ) . sendKeys ( 'foobar' ) . perform ( )
190209
191- assert . strictEqual ( await el . getProperty ( 'value' ) , 'foobar' )
210+ await driver . wait (
211+ async ( ) => {
212+ assert . strictEqual ( await el . getProperty ( 'value' ) , 'foobar' )
213+ return true
214+ } , 10000 )
192215 } )
193216
194217 it ( 'can send keys to focused element (with modifiers)' , async function ( ) {
@@ -208,7 +231,11 @@ suite(function (env) {
208231 . sendKeys ( 'ar' )
209232 . perform ( )
210233
211- assert . strictEqual ( await el . getAttribute ( 'value' ) , 'foOBar' )
234+ await driver . wait (
235+ async ( ) => {
236+ assert . strictEqual ( await el . getAttribute ( 'value' ) , 'foOBar' )
237+ return true
238+ } , 10000 )
212239 } )
213240
214241 it ( 'can interact with simple form elements' , async function ( ) {
@@ -219,7 +246,11 @@ suite(function (env) {
219246
220247 await driver . actions ( ) . click ( el ) . sendKeys ( 'foobar' ) . perform ( )
221248
222- assert . strictEqual ( await el . getAttribute ( 'value' ) , 'foobar' )
249+ await driver . wait (
250+ async ( ) => {
251+ assert . strictEqual ( await el . getAttribute ( 'value' ) , 'foobar' )
252+ return true
253+ } , 10000 )
223254 } )
224255
225256 ignore ( env . browsers ( Browser . FIREFOX , Browser . SAFARI ) )
@@ -237,7 +268,12 @@ suite(function (env) {
237268 } )
238269
239270 async function _getEvents ( driver ) {
240- return await driver . executeScript ( "return allEvents.events;" ) || [ ]
271+ await driver . wait (
272+ async ( ) => {
273+ const events = await driver . executeScript ( 'return allEvents.events;' )
274+ return events . length > 0
275+ } , 5000 )
276+ return await driver . executeScript ( 'return allEvents.events;' ) || [ ]
241277 }
242278 } )
243279} )
0 commit comments