appium / appium-windows-driver

Appium's interface to WindowsAppDriver provided by Microsoft
Apache License 2.0
131 stars 35 forks source link

Help: Do we have any method to hover on element #177

Closed pppppino closed 1 year ago

pppppino commented 1 year ago

Do we have any method to hover on element, such as "windows: hover", then I can execute_script() to achieve it

naeemakram commented 1 year ago

You can use the Actions class and move your cursor to any UI element you want to hover on. A separate "Hover" method is not available. You can do something like this:

IWebElement target = driver.findElement(By.XPath(""));
Actions actions = new Actions(driver);
actions.moveToElement(target).perform();
pppppino commented 1 year ago

@naeemakram , Thanks, I have tried the provided method above, but I got an Exception:

>       raise exception_class(msg=message, stacktrace=format_stacktrace(stacktrace))
E       selenium.common.exceptions.UnknownMethodException: Message: Currently only pen and touch pointer input source types are supported
E       Stacktrace:
E       UnsupportedOperationError: Currently only pen and touch pointer input source types are supported
E           at errorFromW3CJsonCode (C:\Users\QA\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:780:25)
E           at ProxyRequestError.getActualError (C:\Users\QA\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:663:14)
E           at asyncHandler (C:\Users\QA\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:373:25)
mykola-mokhnach commented 1 year ago

Upgrade the driver to the most recent version and try windows: hover extension

pppppino commented 1 year ago

@mykola-mokhnach Thanks, after tried this, I got an Exception: selenium.common.exceptions.UnknownMethodException: Message: Unknown windows command 'hover'. Only startRecordingScreen,stopRecordingScreen,deleteFile,deleteFolder commands are supported.

My Appium-Python-Client pip package is latest. what should I do next, what did you mean "upgrade the driver to the most recent version", you mean appium server?

mykola-mokhnach commented 1 year ago

Make sure you use the driver supplied with Appium 2. Version 1 is not supported anymore

pppppino commented 1 year ago

@mykola-mokhnach Hi, I updated and tried windows: hover, self.driver.execute_script('windows: hover', {"startElementId": ele.id}), then I got an exception: selenium.common.exceptions.InvalidArgumentException: Message: Starting hover point: Either element identifier or absolute coordinates must be provided

then I tried: self.driver.execute_script('windows: hover', { "startElementId": ele.id, "endElementId": ele.id, "modifierKeys": "win", "durationMs": 2000 }) then I got another Exception: Original error: aggregate error I just want to hover on one element, which argument should I use?

mykola-mokhnach commented 1 year ago

I assume in order to emulate hover start and end coordinates must be different, even if this is the same element.

Also, I need the full server log to be able to investigate actual issues. Exception messages are not enough.

pppppino commented 1 year ago

@mykola-mokhnach , Thanks your time!

Env:

Appium server: 2.0.0
Windows driver: 2.9.1
Appium-Python-Client: 2.11.1

My Code: self.driver.execute_script('windows: hover', {"startElementId": ele.id, "endElementId": ele.id, "durationMs": 1500})

My Exception Info: Original error: aggregate error

Server Log:

[debug] [WindowsDriver@573a (0905d066)] Calling AppiumDriver.execute() with args: ["windows: hover",[{"startElementId":"3daacf4a-a41e-4bdb-aede-106c6dbfdc24","endElementId":"3daacf4a-a41e-4bdb-aede-106c6dbfdc24","durationMs":1500}],"0905d066-9dac-4354-ac0d-53dc24f4b3b0"] [WindowsDriver@573a (0905d066)] Executing extension command 'windows: hover' [debug] [WindowsDriver@573a (0905d066)] Matched '/element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/location' to command name 'getLocation' [debug] [WindowsDriver@573a (0905d066)] Proxying [GET /element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/location] to [GET http://127.0.0.1:4724/wd/hub/session/DE081851-1130-4A07-AF06-1D45B9C17683/element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/location] with no body [debug] [WindowsDriver@573a (0905d066)] Matched '/element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/location' to command name 'getLocation' [debug] [WindowsDriver@573a (0905d066)] Proxying [GET /element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/location] to [GET http://127.0.0.1:4724/wd/hub/session/DE081851-1130-4A07-AF06-1D45B9C17683/element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/location] with no body [debug] [WindowsDriver@573a (0905d066)] ========================================== [debug] [WindowsDriver@573a (0905d066)] GET /wd/hub/session/DE081851-1130-4A07-AF06-1D45B9C17683/element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/location HTTP/1.1 [debug] [WindowsDriver@573a (0905d066)] Accept: application/json, / [debug] [WindowsDriver@573a (0905d066)] Accept-Encoding: gzip, compress, deflate, br [debug] [WindowsDriver@573a (0905d066)] Connection: keep-alive [debug] [WindowsDriver@573a (0905d066)] Content-Type: application/json; charset=utf-8 [debug] [WindowsDriver@573a (0905d066)] Host: 127.0.0.1:4724 [debug] [WindowsDriver@573a (0905d066)] User-Agent: appium [debug] [WindowsDriver@573a (0905d066)] ========================================== [debug] [WindowsDriver@573a (0905d066)] GET /wd/hub/session/DE081851-1130-4A07-AF06-1D45B9C17683/element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/location HTTP/1.1 [debug] [WindowsDriver@573a (0905d066)] Accept: application/json, / [debug] [WindowsDriver@573a (0905d066)] Accept-Encoding: gzip, compress, deflate, br [debug] [WindowsDriver@573a (0905d066)] Connection: keep-alive [debug] [WindowsDriver@573a (0905d066)] Content-Type: application/json; charset=utf-8 [debug] [WindowsDriver@573a (0905d066)] Host: 127.0.0.1:4724 [debug] [WindowsDriver@573a (0905d066)] User-Agent: appium [debug] [WindowsDriver@573a (0905d066)] HTTP/1.1 200 OK [debug] [WindowsDriver@573a (0905d066)] Content-Length: 89 [debug] [WindowsDriver@573a (0905d066)] Content-Type: application/json [debug] [WindowsDriver@573a (0905d066)] [debug] [WindowsDriver@573a (0905d066)] {"sessionId":"DE081851-1130-4A07-AF06-1D45B9C17683","status":0,"value":{"x":352,"y":315}} [debug] [WindowsDriver@573a (0905d066)] Got response with status 200: {"sessionId":"DE081851-1130-4A07-AF06-1D45B9C17683","status":0,"value":{"x":352,"y":315}} [debug] [WindowsDriver@573a (0905d066)] Matched '/element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/size' to command name 'getSize' [debug] [WindowsDriver@573a (0905d066)] Proxying [GET /element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/size] to [GET http://127.0.0.1:4724/wd/hub/session/DE081851-1130-4A07-AF06-1D45B9C17683/element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/size] with no body [debug] [WindowsDriver@573a (0905d066)] HTTP/1.1 200 OK [debug] [WindowsDriver@573a (0905d066)] Content-Length: 89 [debug] [WindowsDriver@573a (0905d066)] Content-Type: application/json [debug] [WindowsDriver@573a (0905d066)] [debug] [WindowsDriver@573a (0905d066)] {"sessionId":"DE081851-1130-4A07-AF06-1D45B9C17683","status":0,"value":{"x":352,"y":315}} [debug] [WindowsDriver@573a (0905d066)] Got response with status 200: {"sessionId":"DE081851-1130-4A07-AF06-1D45B9C17683","status":0,"value":{"x":352,"y":315}} [debug] [WindowsDriver@573a (0905d066)] Matched '/element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/size' to command name 'getSize' [debug] [WindowsDriver@573a (0905d066)] Proxying [GET /element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/size] to [GET http://127.0.0.1:4724/wd/hub/session/DE081851-1130-4A07-AF06-1D45B9C17683/element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/size] with no body [debug] [WindowsDriver@573a (0905d066)] ========================================== [debug] [WindowsDriver@573a (0905d066)] GET /wd/hub/session/DE081851-1130-4A07-AF06-1D45B9C17683/element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/size HTTP/1.1 [debug] [WindowsDriver@573a (0905d066)] Accept: application/json, / [debug] [WindowsDriver@573a (0905d066)] Accept-Encoding: gzip, compress, deflate, br [debug] [WindowsDriver@573a (0905d066)] Connection: keep-alive [debug] [WindowsDriver@573a (0905d066)] Content-Type: application/json; charset=utf-8 [debug] [WindowsDriver@573a (0905d066)] Host: 127.0.0.1:4724 [debug] [WindowsDriver@573a (0905d066)] User-Agent: appium [debug] [WindowsDriver@573a (0905d066)] ========================================== [debug] [WindowsDriver@573a (0905d066)] GET /wd/hub/session/DE081851-1130-4A07-AF06-1D45B9C17683/element/3daacf4a-a41e-4bdb-aede-106c6dbfdc24/size HTTP/1.1 [debug] [WindowsDriver@573a (0905d066)] Accept: application/json, / [debug] [WindowsDriver@573a (0905d066)] Accept-Encoding: gzip, compress, deflate, br [debug] [WindowsDriver@573a (0905d066)] Connection: keep-alive [debug] [WindowsDriver@573a (0905d066)] Content-Type: application/json; charset=utf-8 [debug] [WindowsDriver@573a (0905d066)] Host: 127.0.0.1:4724 [debug] [WindowsDriver@573a (0905d066)] User-Agent: appium [debug] [WindowsDriver@573a (0905d066)] HTTP/1.1 200 OK [debug] [WindowsDriver@573a (0905d066)] Content-Length: 97 [debug] [WindowsDriver@573a (0905d066)] Content-Type: application/json [debug] [WindowsDriver@573a (0905d066)] [debug] [WindowsDriver@573a (0905d066)] {"sessionId":"DE081851-1130-4A07-AF06-1D45B9C17683","status":0,"value":{"height":32,"width":199}} [debug] [WindowsDriver@573a (0905d066)] Got response with status 200: {"sessionId":"DE081851-1130-4A07-AF06-1D45B9C17683","status":0,"value":{"height":32,"width":199}} [debug] [WindowsDriver@573a (0905d066)] Starting hover point: Absolute coordinates: (451.5, 331) [debug] [WindowsDriver@573a (0905d066)] HTTP/1.1 200 OK [debug] [WindowsDriver@573a (0905d066)] Content-Length: 97 [debug] [WindowsDriver@573a (0905d066)] Content-Type: application/json [debug] [WindowsDriver@573a (0905d066)] [debug] [WindowsDriver@573a (0905d066)] {"sessionId":"DE081851-1130-4A07-AF06-1D45B9C17683","status":0,"value":{"height":32,"width":199}} [debug] [WindowsDriver@573a (0905d066)] Got response with status 200: {"sessionId":"DE081851-1130-4A07-AF06-1D45B9C17683","status":0,"value":{"height":32,"width":199}} [debug] [WindowsDriver@573a (0905d066)] Ending hover point: Absolute coordinates: (451.5, 331) [debug] [WindowsDriver@573a (0905d066)] Encountered internal error running command: AggregateError: aggregate error [debug] [WindowsDriver@573a (0905d066)] at SomePromiseArray._checkOutcome (C:\Users\admin.appium\node_modules\appium-windows-driver\node_modules\bluebird\js\release\some.js:82:17) [debug] [WindowsDriver@573a (0905d066)] at SomePromiseArray._promiseRejected (C:\Users\admin.appium\node_modules\appium-windows-driver\node_modules\bluebird\js\release\some.js:69:17) [debug] [WindowsDriver@573a (0905d066)] at Promise._settlePromise (C:\Users\admin.appium\node_modules\appium-windows-driver\node_modules\bluebird\js\release\promise.js:611:26) [debug] [WindowsDriver@573a (0905d066)] at Promise._settlePromise0 (C:\Users\admin.appium\node_modules\appium-windows-driver\node_modules\bluebird\js\release\promise.js:649:10) [debug] [WindowsDriver@573a (0905d066)] at Promise._settlePromises (C:\Users\admin.appium\node_modules\appium-windows-driver\node_modules\bluebird\js\release\promise.js:725:18) [debug] [WindowsDriver@573a (0905d066)] at _drainQueueStep (C:\Users\admin.appium\node_modules\appium-windows-driver\node_modules\bluebird\js\release\async.js:93:12) [debug] [WindowsDriver@573a (0905d066)] at _drainQueue (C:\Users\admin.appium\node_modules\appium-windows-driver\node_modules\bluebird\js\release\async.js:86:9) [debug] [WindowsDriver@573a (0905d066)] at Async._drainQueues (C:\Users\admin.appium\node_modules\appium-windows-driver\node_modules\bluebird\js\release\async.js:102:5) [debug] [WindowsDriver@573a (0905d066)] at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\admin.appium\node_modules\appium-windows-driver\node_modules\bluebird\js\release\async.js:15:14) [debug] [WindowsDriver@573a (0905d066)] at processImmediate (node:internal/timers:476:21) [HTTP] <-- POST /session/0905d066-9dac-4354-ac0d-53dc24f4b3b0/execute/sync 500 127 ms - 596 [HTTP] [HTTP] --> GET /session/0905d066-9dac-4354-ac0d-53dc24f4b3b0/screenshot [HTTP] {} [debug] [WindowsDriver@573a (0905d066)] Calling AppiumDriver.getScreenshot() with args: ["0905d066-9dac-4354-ac0d-53dc24f4b3b0"] [debug] [WindowsDriver@573a (0905d066)] Matched '/screenshot' to command name 'getScreenshot' [debug] [WindowsDriver@573a (0905d066)] Proxying [GET /screenshot] to [GET http://127.0.0.1:4724/wd/hub/session/DE081851-1130-4A07-AF06-1D45B9C17683/screenshot] with no body [debug] [WindowsDriver@573a (0905d066)] ==========================================

mykola-mokhnach commented 1 year ago

I assume in order to emulate hover start and end coordinates must be different, even if this is the same element.

I see the above comment has been ignored

pppppino commented 1 year ago

Oh, I got it, I will try it right now

pppppino commented 1 year ago

@mykola-mokhnach , Thanks a lot, Finally, I achieve it; but, I still wanna know, why we must give it an offset?

mykola-mokhnach commented 1 year ago

https://en.wikipedia.org/wiki/Mouseover

In computing, a mouseover, mouse hover or hover box is a graphical control element that is activated when the user moves or hovers the pointer over a trigger area, usually with a mouse, but also possible with a digital pen.

If the trigger area is just a single point then obviously no movement happens and no hover event is registered

dsa45632 commented 11 months ago

can this hover scroll into element if the element is not visible on the page? also, do we have to pass a start element to hover? or can we hover to element from anywhere?

pppppino commented 11 months ago

@dsa45632 , I think, you could get the (x, y) of the position that you wanna hover firstly, then you could hover anywhere!

dsa45632 commented 10 months ago

@dsa45632 , I think, you could get the (x, y) of the position that you wanna hover firstly, then you could hover anywhere! first I need to scroll on the table to make the element visible , so my question is can this hover on the element with scrolling the table? because if I put x and y coordinates it will click on only that location but element needs to be scroll to be clicked