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 @@ -761,6 +761,9 @@ public function click(string $xpath)
761
761
762
762
private function clickOnElement (Element $ element ): void
763
763
{
764
+ // Change the viewport, because Firefox can't move the mouse outside the viewport.
765
+ $ this ->scrollIntoView ($ element );
766
+
764
767
try {
765
768
// Move the mouse to the element as Selenium does not allow clicking on an element which is outside the viewport
766
769
$ this ->getWebDriverSession ()->moveto (array ('element ' => $ element ->getID ()));
@@ -773,6 +776,14 @@ private function clickOnElement(Element $element): void
773
776
$ element ->click ();
774
777
}
775
778
779
+ private function scrollIntoView (Element $ element ): void
780
+ {
781
+ $ this ->executeJsOnElement (
782
+ $ element ,
783
+ "arguments[0].scrollIntoView({ behavior: 'instant', block: 'end', inline: 'nearest' }); "
784
+ );
785
+ }
786
+
776
787
public function doubleClick (string $ xpath )
777
788
{
778
789
$ this ->mouseOver ($ xpath );
@@ -810,8 +821,13 @@ public function isVisible(string $xpath)
810
821
811
822
public function mouseOver (string $ xpath )
812
823
{
824
+ $ element = $ this ->findElement ($ xpath );
825
+
826
+ // Change the viewport, because Firefox can't move the mouse outside the viewport.
827
+ $ this ->scrollIntoView ($ element );
828
+
813
829
$ this ->getWebDriverSession ()->moveto (array (
814
- 'element ' => $ this -> findElement ( $ xpath ) ->getID ()
830
+ 'element ' => $ element ->getID ()
815
831
));
816
832
}
817
833
You can’t perform that action at this time.
0 commit comments