0

I've been playing around with Selenium (chromedriver, Java). I got interested in seeing what it would take to make Selenium move the mouse around in a human-like way; this led me to the Selenium Actions class.

How fast are Selenium Actions performed? I figure this is important to know if I want to move the mouse with a specific velocity. I tried executing the following code:

    Actions builder = new Actions(driver);
    Action action = builder.moveByOffset(4,0).build();
    LocalTime before = LocalTime.now();
    for (int i = 0; i < 100; i++) {
        action.perform();
    }
    LocalTime after = LocalTime.now();
    System.out.println(Duration.between(before, after).toMillis());

If I run the above code with the chrome "developer tools" panel open it runs in ~300ms. With the "developer tools" closed it runs in ~1700ms.

aosborne
  • 371
  • 1
  • 7
  • 1
    Does the html page has any event listener for mouse events ? – Shamit Verma Apr 15 '19 at 06:31
  • My test html page uses the example from the chosen answer here (https://stackoverflow.com/questions/7790725/javascript-track-mouse-position), to draw where the mouse was.this page has event listener on mousemove. – aosborne Apr 15 '19 at 19:52
  • “About:blank” I assumed has now listeners at all... – aosborne Apr 15 '19 at 19:52

1 Answers1

0

ChromeDriver does not support the W3C WebDriver protocol. The JSON-wire protocol does not allow for setting the duration of a mousemove (and is therefore left as an implementation detail for the remote-end).

I’ll be switching the GeckoDriver as it supports W3C WebDriver protocol.

aosborne
  • 371
  • 1
  • 7