diff --git a/src/Selenium2Driver.php b/src/Selenium2Driver.php index 6230f034..61dc80a9 100755 --- a/src/Selenium2Driver.php +++ b/src/Selenium2Driver.php @@ -403,6 +403,7 @@ public function stop() public function reset() { + $this->switchToWindow(); $webDriverSession = $this->getWebDriverSession(); foreach ($this->getWindowNames() as $name) { @@ -410,9 +411,9 @@ public function reset() continue; } - $this->switchToWindow($name); - $webDriverSession->deleteWindow(); - $this->switchToWindow(); + $this->withWindow($name, function () use ($webDriverSession) { + $webDriverSession->deleteWindow(); + }); } $webDriverSession->deleteAllCookies();