Problem/Motivation
The element selector type "CSS, XPath" in PHPDocs in core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
should be lowercase. It can be confusing.
https://www.drupal.org/project/drupal/issues/2892440#comment-13111427
https://www.drupal.org/project/drupal/issues/3041768#comment-13031018
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
index 959b663d20..21a62d22fb 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
@@ -200,7 +200,7 @@ public function waitOnAutocomplete() {
* Drupal CI Javascript tests by default use a viewport of 1024x768px.
*
* @param string $selector_type
- * The element selector type (CSS, XPath).
+ * The element selector type (css, xpath).
* @param string|array $selector
* The element selector. Note: the first found element is used.
* @param bool|string $corner
@@ -243,7 +243,7 @@ public function assertVisibleInViewport($selector_type, $selector, $corner = FAL
* Note: the node should exist in the page, otherwise this assertion fails.
*
* @param string $selector_type
- * The element selector type (CSS, XPath).
+ * The element selector type (css, xpath).
* @param string|array $selector
* The element selector. Note: the first found element is used.
* @param bool|string $corner
vendor/behat/mink/src/Exception/ElementNotFoundException.php
using lowercase in conditional in_array($selector, array('css', 'xpath'))
so $selector
is case sensitive.
class ElementNotFoundException extends ExpectationException
{
/**
* Initializes exception.
*
* @param DriverInterface|Session $driver driver instance
* @param string $type element type
* @param string $selector element selector type
* @param string $locator element locator
*/
public function __construct($driver, $type = null, $selector = null, $locator = null)
{
$message = '';
if (null !== $type) {
$message .= ucfirst($type);
} else {
$message .= 'Tag';
}
if (null !== $locator) {
if (null === $selector || in_array($selector, array('css', 'xpath'))) {
$selector = 'matching '.($selector ?: 'locator');
} else {
$selector = 'with '.$selector;
}
$message .= ' '.$selector.' "'.$locator.'"';
}
$message .= ' not found.';
parent::__construct($message, $driver);
}
}
It means that element selector type should be "css" or "xpath", not "CSS" or "XPath".
/**
* Checks that specific element exists on the current page.
*
* @param string $selectorType element selector type (css, xpath)
* @param string|array $selector element selector
* @param ElementInterface $container document to check against
*
* @return NodeElement
*
* @throws ElementNotFoundException
*/
public function elementExists($selectorType, $selector, ElementInterface $container = null)
{
$container = $container ?: $this->session->getPage();
$node = $container->find($selectorType, $selector);
if (null === $node) {
if (is_array($selector)) {
$selector = implode(' ', $selector);
}
throw new ElementNotFoundException($this->session->getDriver(), 'element', $selectorType, $selector);
}
return $node;
}
Proposed resolution
Change "CSS, XPath" to lowercase.
Remaining tasks
Check if it occurs in other files.
Comment | File | Size | Author |
---|---|---|---|
#14 | interdiff_3041900_12-14.txt | 969 bytes | ankithashetty |
#14 | 3041900-14.patch | 1.1 KB | ankithashetty |
#12 | 3041900-12.patch | 1.1 KB | yogeshmpawar |
#2 | 3041900-2.patch | 1.14 KB | Krzysztof Domański |
Comments
Comment #2
Krzysztof DomańskiOnly two cases.
Comment #3
Krzysztof DomańskiComment #4
Krzysztof DomańskiComment #10
longwaveThe patch looks sensible and matches the other cases already in core:
However it needs a minor reroll before it can be committed.
Comment #11
yogeshmpawarWorking on it.
Comment #12
yogeshmpawarAdded updated patch.
Comment #13
longwave"XPath" should also be in all lowercase in both places.
Comment #14
ankithashettyUpdated the patch, thanks!
Before patch:
After patch:
Comment #15
longwaveThank you, this looks good to go now.
Comment #18
lauriiiCommitted 3e14e0b and pushed to 10.0.x. Also cherry-picked to 9.4.x and 9.3.x since this impacts only documentation. Thanks!