Skip to content

Commit

Permalink
Added protection against closing window from non-existing context
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 committed Mar 21, 2024
1 parent acca0da commit 867a928
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Selenium2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,17 @@ public function stop()

public function reset()
{
$this->switchToWindow();
$webDriverSession = $this->getWebDriverSession();

foreach ($this->getWindowNames() as $name) {
if ($name === $this->initialWindowName) {
continue;
}

$this->switchToWindow($name);
$webDriverSession->deleteWindow();
$this->switchToWindow();
$this->withWindow($name, function () use ($webDriverSession) {
$webDriverSession->deleteWindow();
});
}

$webDriverSession->deleteAllCookies();
Expand Down

0 comments on commit 867a928

Please sign in to comment.