We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3a0cb1c commit 65d5003Copy full SHA for 65d5003
src/Codeception/Module/WebDriver.php
@@ -3575,8 +3575,12 @@ protected function getRelativeTabHandle($offset)
3575
3576
$handle = $this->webDriver->getWindowHandle();
3577
$handles = $this->webDriver->getWindowHandles();
3578
- $idx = array_search($handle, $handles);
3579
- return $handles[($idx + $offset) % count($handles)];
+ $currentHandleIdx = array_search($handle, $handles);
+ $newHandleIdx = ($currentHandleIdx + $offset) % count($handles);
3580
+ if ($newHandleIdx < 0) {
3581
+ $newHandleIdx = count($handles) + $newHandleIdx;
3582
+ }
3583
+ return $handles[$newHandleIdx];
3584
}
3585
3586
/**
0 commit comments