@@ -23,7 +23,6 @@ const fileServer = require('../lib/test/fileserver')
2323const { ignore, Pages, suite } = require ( '../lib/test' )
2424const { Key, Origin } = require ( '../lib/input' )
2525const { Browser, By, until } = require ( '..' )
26- const io = require ( '../io' )
2726
2827suite ( function ( env ) {
2928 describe ( 'WebDriver.actions()' , function ( ) {
@@ -77,9 +76,12 @@ suite(function (env) {
7776 await driver . wait (
7877 async ( ) => {
7978 const clicks = await driver . executeScript ( 'return clicks' )
80- assert . deepStrictEqual ( clicks , [ [ 250 , 250 ] ] )
81- return true
82- } , 10000 )
79+ return clicks . length > 0
80+ } ,
81+ 10000 ,
82+ 'No clicks returned' )
83+ const clicks = await driver . executeScript ( 'return clicks' )
84+ assert . deepStrictEqual ( clicks , [ [ 250 , 250 ] ] )
8385 } )
8486
8587 it ( 'can move relative to element center' , async function ( ) {
@@ -98,9 +100,12 @@ suite(function (env) {
98100 await driver . wait (
99101 async ( ) => {
100102 const clicks = await driver . executeScript ( 'return clicks' )
101- assert . deepStrictEqual ( clicks , [ [ 260 , 260 ] ] )
102- return true
103- } , 10000 )
103+ return clicks . length > 0
104+ } ,
105+ 10000 ,
106+ 'No clicks returned' )
107+ const clicks = await driver . executeScript ( 'return clicks' )
108+ assert . deepStrictEqual ( clicks , [ [ 260 , 260 ] ] )
104109 } )
105110
106111 ignore ( env . browsers ( Browser . SAFARI ) )
@@ -112,10 +117,8 @@ suite(function (env) {
112117
113118 await driver . actions ( ) . doubleClick ( box ) . perform ( )
114119 await driver . wait (
115- async ( ) => {
116- assert . strictEqual ( await box . getAttribute ( 'class' ) , 'blue' )
117- return true
118- } , 10000 )
120+ async ( ) => await box . getAttribute ( 'class' ) === 'blue' , 10000 )
121+ assert . strictEqual ( await box . getAttribute ( 'class' ) , 'blue' )
119122 } )
120123
121124 // For some reason for Chrome 75 we need to wrap this test in an extra
@@ -159,11 +162,9 @@ suite(function (env) {
159162 . perform ( )
160163
161164 await driver . wait (
162- async ( ) => {
163- assert . strictEqual ( await slide . getCssValue ( 'left' ) , '101px' )
164- assert . strictEqual ( await slide . getCssValue ( 'left' ) , '101px' )
165- return true
166- } , 10000 )
165+ async ( ) => await slide . getCssValue ( 'left' ) === '101px' , 10000 )
166+ assert . strictEqual ( await slide . getCssValue ( 'left' ) , '101px' )
167+ assert . strictEqual ( await slide . getCssValue ( 'left' ) , '101px' )
167168 } )
168169
169170 it ( 'can move to and click element in an iframe' , async function ( ) {
@@ -191,10 +192,8 @@ suite(function (env) {
191192 await driver . actions ( ) . sendKeys ( 'foobar' ) . perform ( )
192193
193194 await driver . wait (
194- async ( ) => {
195- assert . strictEqual ( await el . getAttribute ( 'value' ) , 'foobar' )
196- return true
197- } , 10000 )
195+ async ( ) => await el . getAttribute ( 'value' ) === 'foobar' , 10000 )
196+ assert . strictEqual ( await el . getAttribute ( 'value' ) , 'foobar' )
198197 } )
199198
200199 it ( 'can get the property of element' , async function ( ) {
@@ -208,10 +207,8 @@ suite(function (env) {
208207 await driver . actions ( ) . sendKeys ( 'foobar' ) . perform ( )
209208
210209 await driver . wait (
211- async ( ) => {
212- assert . strictEqual ( await el . getProperty ( 'value' ) , 'foobar' )
213- return true
214- } , 10000 )
210+ async ( ) => await el . getProperty ( 'value' ) === 'foobar' , 10000 )
211+ assert . strictEqual ( await el . getProperty ( 'value' ) , 'foobar' )
215212 } )
216213
217214 it ( 'can send keys to focused element (with modifiers)' , async function ( ) {
@@ -232,10 +229,8 @@ suite(function (env) {
232229 . perform ( )
233230
234231 await driver . wait (
235- async ( ) => {
236- assert . strictEqual ( await el . getAttribute ( 'value' ) , 'foOBar' )
237- return true
238- } , 10000 )
232+ async ( ) => await el . getAttribute ( 'value' ) === 'foOBar' , 10000 )
233+ assert . strictEqual ( await el . getAttribute ( 'value' ) , 'foOBar' )
239234 } )
240235
241236 it ( 'can interact with simple form elements' , async function ( ) {
@@ -247,10 +242,8 @@ suite(function (env) {
247242 await driver . actions ( ) . click ( el ) . sendKeys ( 'foobar' ) . perform ( )
248243
249244 await driver . wait (
250- async ( ) => {
251- assert . strictEqual ( await el . getAttribute ( 'value' ) , 'foobar' )
252- return true
253- } , 10000 )
245+ async ( ) => await el . getAttribute ( 'value' ) === 'foobar' , 10000 )
246+ assert . strictEqual ( await el . getAttribute ( 'value' ) , 'foobar' )
254247 } )
255248
256249 ignore ( env . browsers ( Browser . FIREFOX , Browser . SAFARI ) )
0 commit comments