Skip to content

Commit 27d47ae

Browse files
committed
prevent switching to a tab if the last tab is closed
1 parent 65d5003 commit 27d47ae

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
@@ -3527,9 +3527,12 @@ public function seeNumberOfTabs(int $number): void
35273527
*/
35283528
public function closeTab(): void
35293529
{
3530+
$currentTab = $this->webDriver->getWindowHandle();
35303531
$prevTab = $this->getRelativeTabHandle(-1);
35313532
$this->webDriver->close();
3532-
$this->webDriver->switchTo()->window($prevTab);
3533+
if ($prevTab !== $currentTab) {
3534+
$this->webDriver->switchTo()->window($prevTab);
3535+
}
35333536
}
35343537

35353538
/**

0 commit comments

Comments
 (0)