MDL-69136 behat: Support find on a NodeElement
authorAndrew Nicols <andrew@nicols.co.uk>
Mon, 29 Jun 2020 03:27:05 +0000 (11:27 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Mon, 29 Jun 2020 03:36:30 +0000 (11:36 +0800)
lib/behat/behat_base.php

index 729ac1e..c97f492 100644 (file)
@@ -119,6 +119,11 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext {
      * @return NodeElement
      */
     protected function find($selector, $locator, $exception = false, $node = false, $timeout = false) {
+        if ($selector === 'NodeElement' && is_a($locator, NodeElement::class)) {
+            // Support a NodeElement being passed in for use in step chaining.
+            return $locator;
+        }
+
         // Returns the first match.
         $items = $this->find_all($selector, $locator, $exception, $node, $timeout);
         return count($items) ? reset($items) : null;