FuckTheWorld / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

mousemove should honor button state from buttonDown #889

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Issue Description:

I'm trying to use chromedriver for gesture testing related to mouse dragging.
However, it seems that mousemoves issued by chromedriver do not keep the button 
state from a buttonDown command like other drivers do.

Steps to reproduce (if relevant, you MUST provide a simplified html page or
link to public site):

0. Install NodeJS
1. npm install wd, a webdriver library implementing the jsonwire prototcol
2. run node ./drivertest.js

Expected Output:
mouse button 0 down
move mouse 100px right
move mouse 200px right
release mouse button 0
[ 'mousedown 1', 'mousemove 1', 'mousemove 1', 'mouseup 1' ]

Actual Output:
mouse button 0 down
move mouse 100px right
move mouse 200px right
release mouse button 0
[ 'mousedown 1', 'mousemove 0', 'mousemove 0', 'mouseup 1' ]

Attached chromedriver log. You can at timestamp [8.203], the mousedown has 
button: "left", but at timestamp [8.224], the mousemove has button: "none"

Original issue reported on code.google.com by dfre...@chromium.org on 21 Aug 2014 at 9:27

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by mmcnu...@chromium.org on 21 Aug 2014 at 9:34

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:18

GoogleCodeExporter commented 9 years ago
Issue is reproducible with chromedriver:2.15

Sample Html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>WebDriver drag test</title>
<style>
#target {
        height: 500px;
        width: 500px;
        background: orange;
}

#eves {
position: fixed;
left: 600px;
top: 50px;        
}
</style>
</head>
<body>
        <div id="target"></div>
        </br>
        <div id="eves"></div>
        <script>
                var eventLog = [];
                function addToLog(ev) {
                        eventLog.push(ev.type + ' ' + (ev.buttons || ev.which));
                        document.getElementById("eves").innerHTML += eventLog.length + ' '
                                        + ev.type + ' ' + (ev.buttons || ev.which) + '</br>';
                }
                document.addEventListener('mousedown', function(ev) {
                        document.addEventListener('mousemove', addToLog);
                        addToLog(ev);
                });
                document.addEventListener('mouseup', function(ev) {
                        document.removeEventListener('mousemove', addToLog);
                        addToLog(ev);
                });
        </script>
</body>
</html>

Sample Code:
public static void main(String[] args) {
                chrome();
                firefox();
        }

        private static void chrome() {

                LoggingPreferences logPrefs = new LoggingPreferences();
                logPrefs.enable(LogType.BROWSER, Level.ALL);
                logPrefs.enable(LogType.CLIENT, Level.ALL);
                logPrefs.enable(LogType.SERVER, Level.ALL);
                logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
                logPrefs.enable(LogType.DRIVER, Level.ALL);

                DesiredCapabilities caps = DesiredCapabilities.chrome();
                caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
                WebDriver driver=null;
                try {
                        driver = new RemoteWebDriver(new URL("http://localhost:9515"),caps);
                } catch (MalformedURLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                doActions(driver);
        }

        private static void firefox() {
                WebDriver driver = new FirefoxDriver();
                doActions(driver);
        }

        private static void doActions(WebDriver driver) {
                driver.get("file://" + Utility.getPath("Html/Bug_889.html"));
                WebElement element = driver.findElement(By.id("target"));
                Actions actions = new Actions(driver);

                actions.moveToElement(element).clickAndHold(element).moveToElement(null, 100, 0).pause(200);
                actions.moveToElement(null, 200, 0).pause(200).release().pause(200);

                actions.build().perform();

                System.out.println(((JavascriptExecutor) driver).executeScript("return window.eventLog;"));

        }

Original comment by ssudunag...@chromium.org on 20 Apr 2015 at 6:11

GoogleCodeExporter commented 9 years ago
Issue 860 has been merged into this issue.

Original comment by ssudunag...@chromium.org on 20 Apr 2015 at 8:11

GoogleCodeExporter commented 9 years ago

Original comment by gmanikp...@chromium.org on 26 May 2015 at 11:35