MDL-67668 behat: Support NodeElement when fetching node in container

This is similar to change made in MDL-69136 to allow an already-fetched
NodeElement to be provided to the get_node_in_container() function and
makes it easier to be deterministic when writing steps.
This commit is contained in:
Andrew Nicols 2020-11-12 08:15:55 +08:00
parent c8d33eb9ce
commit 1144969755

View file

@ -467,10 +467,16 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext {
* @return NodeElement * @return NodeElement
*/ */
protected function get_node_in_container($selectortype, $element, $containerselectortype, $containerelement) { protected function get_node_in_container($selectortype, $element, $containerselectortype, $containerelement) {
// Gets the container, it will always be text based. if ($containerselectortype === 'NodeElement' && is_a($containerelement, NodeElement::class)) {
$containernode = $this->get_text_selector_node($containerselectortype, $containerelement); // Support a NodeElement being passed in for use in step chaining.
$containernode = $containerelement;
$locatorexceptionmsg = $element;
} else {
// Gets the container, it will always be text based.
$containernode = $this->get_text_selector_node($containerselectortype, $containerelement);
$locatorexceptionmsg = $element . '" in the "' . $containerelement. '" "' . $containerselectortype. '"';
}
$locatorexceptionmsg = $element . '" in the "' . $containerelement. '" "' . $containerselectortype. '"';
$exception = new ElementNotFoundException($this->getSession(), $selectortype, null, $locatorexceptionmsg); $exception = new ElementNotFoundException($this->getSession(), $selectortype, null, $locatorexceptionmsg);
return $this->find($selectortype, $element, $exception, $containernode); return $this->find($selectortype, $element, $exception, $containernode);