File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -768,6 +768,9 @@ public function click(string $xpath)
768768
769769 private function clickOnElement (Element $ element ): void
770770 {
771+ // Change the viewport, because Firefox can't move the mouse outside the viewport.
772+ $ this ->scrollIntoView ($ element );
773+
771774 try {
772775 // Move the mouse to the element as Selenium does not allow clicking on an element which is outside the viewport
773776 $ this ->getWebDriverSession ()->moveto (array ('element ' => $ element ->getID ()));
@@ -780,6 +783,14 @@ private function clickOnElement(Element $element): void
780783 $ element ->click ();
781784 }
782785
786+ private function scrollIntoView (Element $ element ): void
787+ {
788+ $ this ->executeJsOnElement (
789+ $ element ,
790+ "arguments[0].scrollIntoView({ behavior: 'instant', block: 'end', inline: 'nearest' }); "
791+ );
792+ }
793+
783794 public function doubleClick (string $ xpath )
784795 {
785796 $ this ->mouseOver ($ xpath );
@@ -817,8 +828,13 @@ public function isVisible(string $xpath)
817828
818829 public function mouseOver (string $ xpath )
819830 {
831+ $ element = $ this ->findElement ($ xpath );
832+
833+ // Change the viewport, because Firefox can't move the mouse outside the viewport.
834+ $ this ->scrollIntoView ($ element );
835+
820836 $ this ->getWebDriverSession ()->moveto (array (
821- 'element ' => $ this -> findElement ( $ xpath ) ->getID ()
837+ 'element ' => $ element ->getID ()
822838 ));
823839 }
824840
You can’t perform that action at this time.
0 commit comments