简体   繁体   中英

How fast are Selenium Webdriver “Actions” performed?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM