selenium-ide icon indicating copy to clipboard operation
selenium-ide copied to clipboard

Mouseout command fails to work for elements with non-integer heights

Open GeorgeSchneelochVA opened this issue 2 years ago • 5 comments

🐛 Bug Report

On selenium-side-runner, mouse out commands cause an error message if the height is not an integer

To Reproduce

I made a JSFiddle with a div with a 30.5 pixel height: https://jsfiddle.net/va6b51t4/. It just contains this div:

<div style="height: 30.5px; background-color: lightblue;">
  Hello world
</div>

I wrote a side file which executes a mouse out for that div:

{
  "id": "ab1e650e-b8a7-45fc-af17-aad7dc6ca028",
  "version": "2.0",
  "name": "reprocase",
  "url": "https://jsfiddle.net/va6b51t4/",
  "tests": [{
    "id": "0f00339c-288b-47bf-ac81-7318c8686139",
    "name": "reprocase",
    "commands": [{
      "id": "1bf508f0-8868-42e8-8561-b82cdec0b3cc",
      "comment": "",
      "command": "open",
      "target": "https://jsfiddle.net/va6b51t4/",
      "targets": [],
      "value": ""
    }, {
      "id": "61704572-df4f-4b49-9bb1-15ce82ce2ee0",
      "comment": "",
      "command": "setWindowSize",
      "target": "1920x1040",
      "targets": [],
      "value": ""
    }, {
      "id": "fde71dc4-8a22-492f-9166-66f0e9b189b9",
      "comment": "",
      "command": "runScript",
      "target": "window.scrollTo(0,0)",
      "targets": [],
      "value": ""
    }, {
      "id": "09205c11-ca01-4399-b9dc-7352e21f98d3",
      "comment": "",
      "command": "selectFrame",
      "target": "index=0",
      "targets": [
        ["css=html", "css:finder"],
        ["xpath=//html", "xpath:position"]
      ],
      "value": ""
    }, {
      "id": "6f2fffbd-8fbd-471d-934b-a005acb65206",
      "comment": "",
      "command": "mouseOut",
      "target": "css=div",
      "targets": [],
      "value": ""
    }]
  }],
  "suites": [{
    "id": "34c0f914-c3f4-4898-99f5-32ec764ea4b9",
    "name": "Default Suite",
    "persistSession": false,
    "parallel": false,
    "timeout": 300,
    "tests": ["0f00339c-288b-47bf-ac81-7318c8686139"]
  }],
  "urls": ["https://jsfiddle.net/", "https://jsfiddle.net/6w2tf8yu/", "https://jsfiddle.net/6w2tf8yu/2/", "https://jsfiddle.net/va6b51t4/"],
  "plugins": []
}

If I run the side file via the browser extension, it runs fine. But when I run using selenium-side-runner I get this error message:

  Running project reprocase
    Running suite Default Suite
      × Running test reprocase (18608 ms)

  ● Running project reprocase › Running suite Default Suite › Running test reprocase

    Operation timed out running command mouseOut:css=div:

      at Timeout.<anonymous> (../@seleniumhq/side-runtime/src/playback-tree/command-node.ts:151:13)

  ● Running project reprocase › Running suite Default Suite › Running test reprocase

    InvalidArgumentError: invalid argument
    from invalid argument: 'y' must be an int
      (Session info: chrome=112.0.5615.139)

      at Object.throwDecodedError (../selenium-webdriver/lib/error.js:524:15)
      at parseHttpResponse (../selenium-webdriver/lib/http.js:601:13)
      at Executor.execute (../selenium-webdriver/lib/http.js:529:28)
          at runMicrotasks (<anonymous>)
      at Driver.execute (../selenium-webdriver/lib/webdriver.js:745:17)
      at Actions.perform (../selenium-webdriver/lib/input.js:1006:5)
      at WebDriverExecutor.doMouseOut (../@seleniumhq/side-runtime/src/webdriver.ts:608:10)
      at CommandNode.retryCommand (../@seleniumhq/side-runtime/src/playback-tree/command-node.ts:156:22)
      at CommandNode.execute (../@seleniumhq/side-runtime/src/playback-tree/command-node.ts:100:20)

Note the 'y' must be an int above

I tried editing the webdriver.js code to use parseInt to convert y to an integer in the mouseOut function and it fixed the issue for me: https://github.com/SeleniumHQ/selenium-ide/blob/trunk/packages/side-runtime/src/webdriver.ts#L609

Expected behavior

The mouse out command should work appropriately for both the browser extension and selenium-side-runner

Project file reproducing this issue (highly encouraged)

See above for side file

Environment

OS: Windows Server 2019 Selenium IDE Version: 3.17.2 Selenium SIDE Runner Version: 4.0.0-alpha.46 Node version: 16.13.1 Browser: Google Chrome Browser Version: 112.0.5615.139

GeorgeSchneelochVA avatar May 10 '23 21:05 GeorgeSchneelochVA

I also encountered the same problem, have you solved it?

NeilXjz avatar Dec 27 '23 03:12 NeilXjz

@NeilXjz I just patched the webdriver.js file:

  • .move({ origin: element, x }) becomes .move({ origin: element, x: parseInt(x) })
  • .move({ origin: element, y }) becomes .move({ origin: element, y: parseInt(y) })
  • coord.split(',').map becomes coord.split(',').filter(n => n.trim()).map

GeorgeSchneelochVA avatar Dec 27 '23 13:12 GeorgeSchneelochVA

@GeorgeSchneelochVA - Nice! Mind if I steal your fix and roll it into the base thing later tonight?

toddtarsi avatar Dec 27 '23 15:12 toddtarsi

@toddtarsi No, go ahead

GeorgeSchneelochVA avatar Dec 27 '23 15:12 GeorgeSchneelochVA

@GeorgeSchneelochVA - Thanks for the heads up, release going out with this fix now 👍

toddtarsi avatar Dec 27 '23 22:12 toddtarsi