diff --git a/lib/behat/behat_base.php b/lib/behat/behat_base.php index 3e7d9d84432..c42d38ef5d7 100644 --- a/lib/behat/behat_base.php +++ b/lib/behat/behat_base.php @@ -197,6 +197,18 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext { * @return array The selector, locator, and container to search within */ public function normalise_selector(string $selector, $locator, Element $container): array { + // Check for specific transformations for this selector type. + $transformfunction = "transform_find_for_{$selector}"; + if (method_exists('behat_selectors', $transformfunction)) { + // A selector-specific transformation exists. + // Perform initial transformation of the selector within the current container. + [ + 'selector' => $selector, + 'locator' => $locator, + 'container' => $container, + ] = behat_selectors::{$transformfunction}($this, $locator, $container); + } + // Normalise the css and xpath selector types. if ('css_element' === $selector) { $selector = 'css';