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)
768
768
769
769
private function clickOnElement (Element $ element ): void
770
770
{
771
+ // Change the viewport, because Firefox can't move the mouse outside the viewport.
772
+ $ this ->scrollIntoView ($ element );
773
+
771
774
try {
772
775
// Move the mouse to the element as Selenium does not allow clicking on an element which is outside the viewport
773
776
$ this ->getWebDriverSession ()->moveto (array ('element ' => $ element ->getID ()));
@@ -780,6 +783,14 @@ private function clickOnElement(Element $element): void
780
783
$ element ->click ();
781
784
}
782
785
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
+
783
794
public function doubleClick (string $ xpath )
784
795
{
785
796
$ this ->mouseOver ($ xpath );
@@ -817,8 +828,13 @@ public function isVisible(string $xpath)
817
828
818
829
public function mouseOver (string $ xpath )
819
830
{
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
+
820
836
$ this ->getWebDriverSession ()->moveto (array (
821
- 'element ' => $ this -> findElement ( $ xpath ) ->getID ()
837
+ 'element ' => $ element ->getID ()
822
838
));
823
839
}
824
840
You can’t perform that action at this time.
0 commit comments