MDL-66550 behat: Add ability to transform a specific selector

This commit is contained in:
Andrew Nicols 2019-09-10 21:29:00 +08:00
parent 700682dc40
commit b983ae4ab8

View File

@ -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';