MDL-39051 behat: Fix issue after closing popup windows

When a step closes a popup window the page DOM is not available
until we switch again to the main window; we should avoid exceptions
at framework level when hooking the after step process, this
includes the new exceptions catcher modification.
This commit is contained in:
David Monllao 2013-05-08 14:01:36 +08:00
parent b576bdc75d
commit 217e8e59e5

View file

@ -208,6 +208,9 @@ class behat_hooks extends behat_base {
*/ */
public function i_look_for_exceptions() { public function i_look_for_exceptions() {
// Wrap in try in case we were interacting with a closed window.
try {
// Exceptions. // Exceptions.
if ($errormsg = $this->getSession()->getPage()->find('css', '.errorbox p.errormessage')) { if ($errormsg = $this->getSession()->getPage()->find('css', '.errorbox p.errormessage')) {
@ -251,6 +254,10 @@ class behat_hooks extends behat_base {
$msg = "Other backtraces found:\n" . implode("\n", $msgs); $msg = "Other backtraces found:\n" . implode("\n", $msgs);
throw new \Exception(htmlentities($msg)); throw new \Exception(htmlentities($msg));
} }
} catch (NoSuchWindow $e) {
// If we were interacting with a popup window it will not exists after closing it.
}
} }
/** /**