Bug description
WebDriverExpectedCondition::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.
Also see: SeleniumHQ/selenium#14427
How could the issue be reproduced
$I->waitForElementClickable('button');
using Codeception Module WebDriver v4.0.2
https://github.com/Codeception/module-webdriver/blob/ef0ea8044eb01dc1e830df27fe431e71440a462f/src/Codeception/Module/WebDriver.php#L2657-L2661
public function waitForElementClickable($element, int $timeout = 10): void
{
$condition = WebDriverExpectedCondition::elementToBeClickable($this->getLocator($element));
$this->webDriver->wait($timeout)->until($condition);
}
Expected behavior
This should not select an element as follows:
HTML:
<button class="disabled">…</button>
CSS:
.disabled {
pointer-events: none;
}
Php-webdriver version
1.12
PHP version
8.3
How do you start the browser driver or Selenium server
Don't know - TYPO3 test environment
Selenium server / Selenium Docker image version
No response
Browser driver (chromedriver/geckodriver...) version
No response
Browser name and version
chrome-headless-shell=124.0.6367.118
Operating system
No response
Additional context
|
/** |
|
* An expectation for checking an element is visible and enabled such that you can click it. |
|
* |
|
* @param WebDriverBy $by The locator used to find the element |
|
* @return static Condition return the WebDriverElement once it is located, visible and clickable. |
|
*/ |
|
public static function elementToBeClickable(WebDriverBy $by) |
|
{ |
|
$visibility_of_element_located = self::visibilityOfElementLocated($by); |
|
|
|
return new static( |
|
function (WebDriver $driver) use ($visibility_of_element_located) { |
|
$element = call_user_func( |
|
$visibility_of_element_located->getApply(), |
|
$driver |
|
); |
|
|
|
try { |
|
if ($element !== null && $element->isEnabled()) { |
|
return $element; |
|
} |
|
|
|
return null; |
|
} catch (StaleElementReferenceException $e) { |
|
return null; |
|
} |
|
} |
|
); |
|
} |
Adding $element->getCSSValue('pointer-events') !== 'none' to the condition might give the expected result.
Bug description
WebDriverExpectedCondition::elementToBeClickable should check if an element is clickable.
Elements that have CSS
pointer-events: noneset are not clickable. This should be considered in the check for clickability.Also see: SeleniumHQ/selenium#14427
How could the issue be reproduced
using Codeception Module WebDriver v4.0.2
https://github.com/Codeception/module-webdriver/blob/ef0ea8044eb01dc1e830df27fe431e71440a462f/src/Codeception/Module/WebDriver.php#L2657-L2661
Expected behavior
This should not select an element as follows:
HTML:
CSS:
Php-webdriver version
1.12
PHP version
8.3
How do you start the browser driver or Selenium server
Don't know - TYPO3 test environment
Selenium server / Selenium Docker image version
No response
Browser driver (chromedriver/geckodriver...) version
No response
Browser name and version
chrome-headless-shell=124.0.6367.118
Operating system
No response
Additional context
php-webdriver/lib/WebDriverExpectedCondition.php
Lines 406 to 434 in 11923b4
Adding
$element->getCSSValue('pointer-events') !== 'none'to the condition might give the expected result.