From 21ac04e12e50726f85ca9e55b07c028bb74782dc Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Tue, 10 Sep 2019 21:24:15 +0800 Subject: [PATCH] MDL-66550 behat: Add ability to transform a specific selector --- lib/behat/behat_base.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/behat/behat_base.php b/lib/behat/behat_base.php index d4ec105ad74..dd80f209060 100644 --- a/lib/behat/behat_base.php +++ b/lib/behat/behat_base.php @@ -188,6 +188,17 @@ 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. + $normalised = behat_selectors::{$transformfunction}($this, $locator, $container); + $selector = $normalised['selector']; + $locator = $normalised['locator']; + $container = $normalised['container']; + } + // Normalise the css and xpath selector types. if ('css_element' === $selector) { $selector = 'css';