diff --git a/src/Selenium2Driver.php b/src/Selenium2Driver.php index 463479be..5185d7c4 100755 --- a/src/Selenium2Driver.php +++ b/src/Selenium2Driver.php @@ -953,8 +953,19 @@ public function mouseOver(string $xpath) private function scrollElementIntoView(Element $element): void { $script = <<= 0 && + rect.left >= 0 && + rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && + rect.right <= (window.innerWidth || document.documentElement.clientWidth) + ); + + if (!inView) { + e.scrollIntoView({ behavior: 'instant', block: 'end', inline: 'nearest' }); + rect = e.getBoundingClientRect(); + } + return {'x': rect.left, 'y': rect.top}; JS;