Skip to content

Commit

Permalink
MDL-58948 behat: catch ElementNotFoundException
Browse files Browse the repository at this point in the history
Another valid exception that can be thrown from a Mink driver
is the ElementNotFoundException when an element has gone missing.
  • Loading branch information
polothy committed Jun 28, 2017
1 parent 3cf0d01 commit f545909
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/behat/form_field/behat_form_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public function key_press($char, $modifier = null) {
// If the JS handler attached to keydown or keypress destroys the element
// the later events may trigger errors because form element no longer exist
// or is not visible. Ignore such exceptions here.
} catch (\Behat\Mink\Exception\ElementNotFoundException $e) {
// Other Mink drivers can throw this for the same reason as above.
}
}

Expand Down
3 changes: 3 additions & 0 deletions lib/tests/behat/behat_general.php
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,9 @@ function($context, $args) {
} catch (WebDriver\Exception\NoSuchElement $e) {
// Do nothing just return, as element is no more on page.
return true;
} catch (ElementNotFoundException $e) {
// Do nothing just return, as element is no more on page.
return true;
}
}

Expand Down

0 comments on commit f545909

Please sign in to comment.