Skip to content

Commit 9919a2a

Browse files
webmaster777Naktibalda
authored andcommitted
prevent switching to a tab if the last tab is closed
1 parent 0eaf97e commit 9919a2a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Codeception/Module/WebDriver.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3505,9 +3505,12 @@ public function seeNumberOfTabs($number): void
35053505
*/
35063506
public function closeTab(): void
35073507
{
3508+
$currentTab = $this->webDriver->getWindowHandle();
35083509
$prevTab = $this->getRelativeTabHandle(-1);
35093510
$this->webDriver->close();
3510-
$this->webDriver->switchTo()->window($prevTab);
3511+
if ($prevTab !== $currentTab) {
3512+
$this->webDriver->switchTo()->window($prevTab);
3513+
}
35113514
}
35123515

35133516
/**

0 commit comments

Comments
 (0)