-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[🐛 Bug]: ExpectedCondition::elementToBeClickable does not consider CSS pointer-events: none
#14427
Comments
@rr-it, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
Just because a pointer-event is set to none doesn't mean an element isn't clickable. To use your example of a disable button: I can click it, but nothing should happen. If I were writing tests for security permissions, for example, I would want to be able to simulate clicking said button when it is enabled and when it is disabled, then assert that the result of clicking the button when enabled does not occur when the button is disabled. |
@shbenzer AFAIK your mentioned case does already not work for buttons "disabled" via
If you trigger a click on a button like
Here the underlying element in the background receives the click instead.
This contradicts what https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events#none says:
E.g. a "really disabled" button via attribute <button disabled>Test</button> Also see: |
While I still believe that elements should be clickable when they're disabled, you do make a good point. I just did some testing in Chrome in Vue.js on a button that is disabled and not only do I similarly get the same
I think this might be evidence of a larger issue, and more than just the
|
IMO reading the docs WebDriver element enabled we might check what's the result of Enabled:
Disabled by attribute
|
Only thing that needed to be upgraded was isEnabled(). Thank you for pointing this out @rr-it |
I'd like to keep a difference between So my conclusion:
|
Is_clickable checks if an element is enabled before clicking - by upgrading is_enabled to handle pointer-events:none, is_clickable should handle it correctly |
Actually someone might want to check for elements that are 'is_enabled' but are not 'is_clickable' at the same time.
I do not want to change any meaning of neither 'is_enabled' nor 'is_clickable'. Button A:
|
Instances where an element is clickable require it to be of the following element types:
These tags are intended to be interacted with, in some way, by the mouse (at minimum by selecting them for keyboard interaction in the case of TagName.TEXTAREA). While, yes, if one of these tags have
@diemol, do you disagree? |
About this comment:
@shbenzer If we go on with your implemenation, it will only tell that a button is disabled for mouse. It won't tell anymore if it is enabled or disabled for keyboard. I would not call a button "effectively disabled" if that button is disabled for mouse only, but is still enabled for keyboard.
|
That is a good point, I hadn't considered that accessibility standards might require a site to be keyboard-only accessible. |
What happened?
The docs mention
static ExpectedCondition<WebElement> elementToBeClickable(By locator)
static ExpectedCondition<WebElement> elementToBeClickable(WebElement element)
So
elementToBeClickable
should check if an element is clickable.Elements that have CSS
pointer-events: none
set are not clickable. This should be considered in the check for clickability.See https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events#values
How can we reproduce the issue?
The following
<button>
-element is not clickable:HTML:
CSS:
But
elementToBeClickable
only checks if an element is there and enabled.It does not check for the CSS property
pointer-event: none
- which might make an element non-clickable.selenium/java/src/org/openqa/selenium/support/ui/ExpectedConditions.java
Lines 617 to 672 in 26f9aa2
Adding
element.getCssValue("pointer-events") != "none"
to the condition might give the expected result.Relevant log output
Operating System
IMO not relevant here
Selenium version
IMO not relevant here
What are the browser(s) and version(s) where you see this issue?
IMO not relevant here
What are the browser driver(s) and version(s) where you see this issue?
IMO not relevant here
Are you using Selenium Grid?
No response
The text was updated successfully, but these errors were encountered: