Skip to content

Commit

Permalink
Close all, but main window during session reset
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 committed Apr 10, 2024
1 parent ec38044 commit e510284
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Selenium2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,20 @@ public function stop()

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

// Close all windows except the initial one.
foreach ($webDriverSession->window_handles() as $windowHandle) {
if ($windowHandle === $this->initialWindowHandle) {
continue;
}

$webDriverSession->focusWindow($windowHandle);
$webDriverSession->deleteWindow();
}

$this->switchToWindow();
$webDriverSession->deleteAllCookies();
}

public function visit(string $url)
Expand Down

0 comments on commit e510284

Please sign in to comment.