0

The system under test records if the user has moved outside of the page, basically to check if the user is copy/pasting the username/ password and other details when filling a form. The test needs to be done in various browsers and different versions of the browser. To automate this test, I am using Actions class. This code works fine with Chrome 90.0 and below. With higher versions of Chrome, org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: move target out of bounds is being thrown.

Please help.

Action mouseOffUserid =
        builder.moveToElement(userid).click().sendKeys(userid, "senkeytestOFFPAGE").moveByOffset(0, -1 * 120).moveByOffset(0, 120).build();

Action mouseOffPsw =
        builder.moveToElement(psw).click().sendKeys(psw, "senkeytestOFFPAGE").moveByOffset(0, -1 * (150 + adjustYOffset)).moveByOffset(0, 150 + adjustYOffset).build();

Action mouseClickUserid = builder.moveToElement(userid).click().sendKeys(userid, "senkeytest").build();
//going off page from userid
mouseOffUserid.perform();
QueryManager.giveDelay(1000);
//going off page from psw
mouseOffPsw.perform();
QueryManager.giveDelay(1000);

Using Robot class as well did not help. The mouse just does not move. I followed [java-robot-class-mousemove-not-going-to-specified-location][1]

`userid.sendKeys("ABC");
      for (int i = 1; i < 3; i++) {
robot.mouseMove(0, 0);
System.out.println("Attempt "+i+" : "+ MouseInfo.getPointerInfo().getLocation().getX() + " , "
                        + MouseInfo.getPointerInfo().getLocation().getY());
            }
            userid.click();
            userid.sendKeys("123");```


  [1]: https://stackoverflow.com/questions/47538559/java-robot-class-mousemove-not-going-to-specified-location
Divya
  • 59
  • 10
  • 1
    You can try `java.awt.Robot` and do `mouseMove(0,0)` – Alexey R. Aug 05 '22 at 07:31
  • Thanks @AlexeyR. I used Robot class but it does not seem to work. I followed [link][https://stackoverflow.com/questions/47538559/java-robot-class-mousemove-not-going-to-specified-location]. The mouse does not move. `userid.sendKeys("ABC"); for (int i = 1; i < 3; i++) { robot.mouseMove(0, 0); System.out.println("Attempt "+i+" : "+ MouseInfo.getPointerInfo().getLocation().getX() + " , " + MouseInfo.getPointerInfo().getLocation().getY()); } userid.click(); userid.sendKeys("123");` – Divya Aug 08 '22 at 02:27

0 Answers0