New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
E2E: Refactor clickWhenClickable() helper #50911
Conversation
62d905a
to
6dc6043
Compare
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
0cf9343
to
f64694a
Compare
@@ -530,7 +529,7 @@ export async function selectElementByText( driver, selector, text ) { | |||
const allElements = await driver.findElements( selector ); | |||
return await webdriver.promise.filter( allElements, getInnerTextMatcherFunction( text ) ); | |||
}; | |||
return await this.clickWhenClickable( driver, element, null, `while looking for '${ text }'` ); | |||
return await this.clickWhenClickable( driver, element ); |
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.
I'm removing this only temporarily. Already working on a refactor that would include displaying similar message in #50944.
There's one failing flaky spec that can be ignored. It's being addressed in #50999. |
12300be
to
c8cebcd
Compare
* @param {By} locator The element's locator | ||
* @returns {WebElementCondition} The new condition | ||
*/ | ||
elementIsClickable( locator ) { |
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.
Neat way to logically group this as a local extension based on the until
object 👍🏻
.getAttribute( 'aria-disabled' ) | ||
.then( ( v ) => v !== 'true' ); | ||
|
||
return isEnabled && isAriaEnabled ? element : null; |
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.
What if / could it happen that the element isEnabled
but not isAriaEnabled
? The &&
here seems to suggest that it might be possible.
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.
Good question, because AFAIK it's how we actually disable elements in Gutenberg (most probably because of the inconsistency issue between screen readers). So when an element is enabled, but at the same time it's aria-disabled="true"
(i.e. the Publish
button) it should be treated just like a disabled element would, which in the result should be a non-clickable/non-actionable element.
Out of curiosity, it'd be great if you could elaborate on why it was failing as a result of being called without an |
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.
Code looks great! I see that the remaining failed Desktop E2E test is related to the loginc magic link, which is being addressed in another PR(s). 🚢
Of course! The |
Changes proposed in this pull request
DriverHelper.clickWhenClickable()
to make sure that element is enabled before clicking. This should address some general flakiness where a clicked element is (initially) disabled (due to i.e. pending request).ensureMobileMenuOpen
helper, where thefindElement
&clickWhenClickable
methods weren't called viaawait
and, as a result, returning an unreliable state of the menu. This PR fixes that.Testing instructions
Specs should pass :)