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 e0aa26c commit 0eaf97eCopy full SHA for 0eaf97e
src/Codeception/Module/WebDriver.php
@@ -3553,8 +3553,12 @@ protected function getRelativeTabHandle($offset)
3553
3554
$handle = $this->webDriver->getWindowHandle();
3555
$handles = $this->webDriver->getWindowHandles();
3556
- $idx = array_search($handle, $handles);
3557
- return $handles[($idx + $offset) % count($handles)];
+ $currentHandleIdx = array_search($handle, $handles);
+ $newHandleIdx = ($currentHandleIdx + $offset) % count($handles);
3558
+ if ($newHandleIdx < 0) {
3559
+ $newHandleIdx = count($handles) + $newHandleIdx;
3560
+ }
3561
+ return $handles[$newHandleIdx];
3562
}
3563
3564
/**
0 commit comments