From d00d145467bb377a53c9275c5661a3f83aa4cf2c Mon Sep 17 00:00:00 2001 From: Alister Scott Date: Mon, 4 Jun 2018 13:59:12 +1000 Subject: [PATCH 1/5] Disable promise manager --- run.sh | 3 +++ scripts/run-wrapper.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/run.sh b/run.sh index f9438563f..8cdbc421f 100755 --- a/run.sh +++ b/run.sh @@ -21,6 +21,9 @@ if [ "$NODE_ENV" = "" ]; then exit 1 fi +#disable selenium promise manager +export SELENIUM_PROMISE_MANAGER=0 + # Function to join arrays into a string function joinStr { local IFS="$1"; shift; echo "$*"; } 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" From e647e97d5228267c41e73753ee6ea59ad6b1a621 Mon Sep 17 00:00:00 2001 From: Alister Scott Date: Fri, 22 Jun 2018 14:07:17 +1000 Subject: [PATCH 2/5] Update Theme Spec --- specs/wp-theme-switch-spec.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/specs/wp-theme-switch-spec.js b/specs/wp-theme-switch-spec.js index fa9f75a68..333e456e2 100755 --- a/specs/wp-theme-switch-spec.js +++ b/specs/wp-theme-switch-spec.js @@ -136,9 +136,7 @@ test.describe( if ( host === 'WPCOM' ) { test.it( 'Can customize the site from the theme thanks dialog', async function() { - let customizerPage = await CustomizerPage.Expect( driver ); - let displayed = await customizerPage.displayed(); - return assert( displayed, 'The customizer page was not displayed' ); + return await CustomizerPage.Expect( driver ); } ); } else { test.it( 'Can log in via Jetpack SSO', async function() { @@ -148,9 +146,7 @@ test.describe( test.it( 'Can customize the site from the theme thanks dialog', async function() { await WPAdminCustomizerPage.refreshIfError( driver ); - const wpAdminCustomizerPage = await WPAdminCustomizerPage.Expect( driver ); - let displayed = await wpAdminCustomizerPage.displayed(); - assert( displayed, 'The customizer page was not displayed' ); + return await WPAdminCustomizerPage.Expect( driver ); } ); } } ); From b1f76346d8dfef170df8b8fe48dad757b55e516e Mon Sep 17 00:00:00 2001 From: Alister Scott Date: Fri, 22 Jun 2018 14:25:07 +1000 Subject: [PATCH 3/5] Update enterAccountNameAndClose to use await --- lib/pages/account/close-account-page.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/pages/account/close-account-page.js b/lib/pages/account/close-account-page.js index 27274df31..d39896b2e 100755 --- a/lib/pages/account/close-account-page.js +++ b/lib/pages/account/close-account-page.js @@ -20,11 +20,18 @@ export default class CloseAccountPage extends AsyncBaseContainer { } async enterAccountNameAndClose( accountName ) { - driverHelper.setWhenSettable( + await driverHelper.setWhenSettable( this.driver, by.css( '.account-close__confirm-dialog-confirm-input' ), accountName ); - return driverHelper.clickWhenClickable( this.driver, by.css( '.dialog button.is-scary' ) ); + await driverHelper.waitTillNotPresent( + this.driver, + by.css( '.dialog button.is-scary[disabled]' ) + ); + return await driverHelper.clickWhenClickable( + this.driver, + by.css( '.dialog button.is-scary' ) + ); } } From 4970bed51af28bd8815653e8df1d5a5fa688e818 Mon Sep 17 00:00:00 2001 From: Alister Scott Date: Fri, 22 Jun 2018 14:58:59 +1000 Subject: [PATCH 4/5] Update drivermanager --- lib/driver-helper.js | 78 +++++++++----------------------------------- 1 file changed, 16 insertions(+), 62 deletions(-) diff --git a/lib/driver-helper.js b/lib/driver-helper.js index 4a1830c0f..0c79601f3 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() { + const element = await driver.findElement( selector ); + await self.waitForFieldClearable( driver, 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 '${ From 69862d15b707413252d3135a9460fb7eab691116 Mon Sep 17 00:00:00 2001 From: Alister Scott Date: Fri, 22 Jun 2018 15:11:43 +1000 Subject: [PATCH 5/5] Udate setWhenSettable --- lib/driver-helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/driver-helper.js b/lib/driver-helper.js index 0c79601f3..fe685d7ca 100755 --- a/lib/driver-helper.js +++ b/lib/driver-helper.js @@ -214,8 +214,8 @@ export async function setWhenSettable( const logValue = secureValue === true ? '*********' : value; return driver.wait( async function() { - const element = await driver.findElement( selector ); await self.waitForFieldClearable( driver, selector ); + const element = await driver.findElement( selector ); if ( pauseBetweenKeysMS === 0 ) { await element.sendKeys( value ); } else {