-
Notifications
You must be signed in to change notification settings - Fork 20
Remove and address sleep
statement in wp-admin-jetpack-page.js
#1739
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ import { By } from 'selenium-webdriver'; | |
|
||
import * as driverHelper from '../../driver-helper'; | ||
import AsyncBaseContainer from '../../async-base-container'; | ||
import config from 'config'; | ||
|
||
const explicitWaitMS = config.get( 'explicitWaitMS' ); | ||
|
||
export default class WPAdminJetpackPage extends AsyncBaseContainer { | ||
constructor( driver ) { | ||
|
@@ -13,8 +16,23 @@ export default class WPAdminJetpackPage extends AsyncBaseContainer { | |
|
||
async connectWordPressCom() { | ||
const selector = By.css( 'a.jp-jetpack-connect__button' ); | ||
const pauseBetweenFocusAttemptsMS = 200; | ||
const connectJetpackButtonFocus = | ||
"document.getElementsByClassName( 'jp-jetpack-connect__button')[0].focus();"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, I'm not quite sure what the problem you trying to fix here, but the connection button will be changed: Automattic/jetpack#8618. Is the issue you trying to fix is somehow related to the fact that button not doing what it should right after page load? It might be a good idea to fix this on Jetpack side instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I am trying to remove and address the https://github.com/Automattic/wp-e2e-tests/pull/584/files#diff-e88aeb376f9b63bf70f5877bdece3966R14 My guess is that the test runs too fast and clicks on the button when it is not ready to be clicked on yet. I was not able to reproduce it locally though. Since you mentioned the button will be changed, it makes sense to see if the issue will be present after the change takes affect. What do you think? |
||
await driverHelper.waitTillPresentAndDisplayed( this.driver, selector ); | ||
await this.driver.sleep( 1000 ); | ||
for ( let i = 0; i < explicitWaitMS / pauseBetweenFocusAttemptsMS; i++ ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this |
||
await this.driver.executeScript( connectJetpackButtonFocus ); | ||
let currentActiveElementId = await this.driver | ||
.switchTo() | ||
.activeElement() | ||
.getId(); | ||
let connectJetpackButtonId = await ( await this.driver.findElement( selector ) ).getId(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are these params around There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, single |
||
|
||
if ( connectJetpackButtonId === currentActiveElementId ) { | ||
break; | ||
} | ||
await this.driver.sleep( pauseBetweenFocusAttemptsMS ); | ||
} | ||
return await driverHelper.clickWhenClickable( this.driver, selector ); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explicitWaitMS
is available inside any PageObject viathis.explicitWaitMS
: https://github.com/Automattic/wp-e2e-tests/blob/master/lib/async-base-container.js#L22There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted, thanks @brbrr 👍