Skip to content

Commit 072a0b7

Browse files
webmaster777Naktibalda
authored andcommitted
prevent switching to a tab if the last tab is closed
1 parent 22e15dd commit 072a0b7

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
@@ -3454,9 +3454,12 @@ public function seeNumberOfTabs($number)
34543454
*/
34553455
public function closeTab()
34563456
{
3457+
$currentTab = $this->webDriver->getWindowHandle();
34573458
$prevTab = $this->getRelativeTabHandle(-1);
34583459
$this->webDriver->close();
3459-
$this->webDriver->switchTo()->window($prevTab);
3460+
if ($prevTab !== $currentTab) {
3461+
$this->webDriver->switchTo()->window($prevTab);
3462+
}
34603463
}
34613464

34623465
/**

0 commit comments

Comments
 (0)