diff --git a/lib/driver-helper.js b/lib/driver-helper.js index 4a1830c0f..fe685d7ca 100755 --- a/lib/driver-helper.js +++ b/lib/driver-helper.js @@ -9,38 +9,9 @@ import * as dataHelper from './data-helper'; const explicitWaitMS = config.get( 'explicitWaitMS' ); const by = webdriver.By; -export function highlightElement( driver, selector, waitOverride ) { - if ( config.has( 'highlightElements' ) && config.get( 'highlightElements' ) ) { - const timeoutWait = waitOverride ? waitOverride : explicitWaitMS; - - function setStyle( element, style ) { - const previous = element.getAttribute( 'style' ); - element.setAttribute( 'style', style ); - setTimeout( () => { - element.setAttribute( 'style', previous ); - }, 200 ); - return 'highlighted'; - } - - let theElement = driver.findElement( selector ); - return driver.wait( - function() { - return driver.executeScript( - setStyle, - theElement, - 'color: red; background-color: yellow;' - ); - }, - timeoutWait, - 'Timed out waiting for element to be Highlighted' - ); - } -} - export function clickWhenClickable( driver, selector, waitOverride ) { const timeoutWait = waitOverride ? waitOverride : explicitWaitMS; - this.highlightElement( driver, selector, waitOverride ); return driver.wait( function() { return driver.findElement( selector ).then( @@ -205,7 +176,7 @@ export function elementIsNotPresent( driver, cssSelector ) { } ); } -export function waitForFieldClearable( driver, selector ) { +export async function waitForFieldClearable( driver, selector ) { return driver.wait( function() { return driver.findElement( selector ).then( @@ -233,45 +204,28 @@ export function waitForFieldClearable( driver, selector ) { ); } -export function setWhenSettable( +export async function setWhenSettable( driver, selector, value, - { secureValue = false, pauseBetweenKeysMS = 0, assumeSuccess = false } = {} + { secureValue = false, pauseBetweenKeysMS = 0 } = {} ) { + const self = this; const logValue = secureValue === true ? '*********' : value; - let self = this; return driver.wait( - function() { - return driver.findElement( selector ).then( - async function( element ) { - await self.waitForFieldClearable( driver, selector ); - if ( pauseBetweenKeysMS === 0 ) { - await element.sendKeys( value ); - } else { - for ( let i = 0; i < value.length; i++ ) { - driver.sleep( pauseBetweenKeysMS ).then( () => { - element.sendKeys( value[ i ] ); - } ); - } - } - - return ( - assumeSuccess || - element.getAttribute( 'value' ).then( - actualValue => { - return actualValue === value; - }, - function() { - return false; - } - ) - ); - }, - function() { - return false; + async function() { + await self.waitForFieldClearable( driver, selector ); + const element = await driver.findElement( selector ); + if ( pauseBetweenKeysMS === 0 ) { + await element.sendKeys( value ); + } else { + for ( let i = 0; i < value.length; i++ ) { + await driver.sleep( pauseBetweenKeysMS ); + await element.sendKeys( value[ i ] ); } - ); + } + const actualValue = await element.getAttribute( 'value' ); + return actualValue === value; }, explicitWaitMS, `Timed out waiting for element with ${ selector.using } of '${ diff --git a/run.sh b/run.sh index 054bc6147..fb21a96ca 100755 --- a/run.sh +++ b/run.sh @@ -14,6 +14,9 @@ RETURN=0 CLEAN=0 GREP="" +#disable selenium promise manager +export SELENIUM_PROMISE_MANAGER=0 + # Warn if NODE_ENV variable is not set if [ "$NODE_ENV" = "" ]; then echo "WARNING: NODE_ENV environment variable is not set." diff --git a/scripts/run-wrapper.sh b/scripts/run-wrapper.sh index 052d509fc..532afbc3a 100755 --- a/scripts/run-wrapper.sh +++ b/scripts/run-wrapper.sh @@ -17,7 +17,7 @@ if [ "$NODE_ENV_OVERRIDE" != "" ]; then fi #disable selenium promise manager -#export SELENIUM_PROMISE_MANAGER=0 +export SELENIUM_PROMISE_MANAGER=0 export TESTARGS="-R -p"