Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DPI compatibility issue when try method in "execute_script" #288

Open
pppppino opened this issue Jan 16, 2025 · 2 comments
Open

DPI compatibility issue when try method in "execute_script" #288

pppppino opened this issue Jan 16, 2025 · 2 comments

Comments

@pppppino
Copy link

pppppino commented Jan 16, 2025

When my windows DPI is 100%, I could rightClick success, while it failed when my windows DPI is 150%, it seems the "rightClick" action worked on the false (x, y)

my code:
self.driver.execute_script('windows: click', {"elementId": self.wait_locator(loc).id, "button": "right"});

at the same time, I have tried other "execute_script" method, including: windows: scroll, windows: hover, "windows: click".
All these method have this issue

DPI Setting: Setting > System > Display > Scale

@pppppino
Copy link
Author

pppppino commented Jan 16, 2025

by the way, no matter what DPI, driver.findElement().click() could always click in the true place

@KazuCocoa
Copy link
Member

It is currently expected to not work with scaled screen.

This driver gets orientation info via WinAppDriver, so if it returns the scaled value, we can support it. But the WAD doesn't support it for now.

const {x: left, y: top} = await this.winAppDriver.sendCommand(`/element/${elementId}/location`, 'GET');
if (!hasX && !hasY) {
const {width, height} = await this.winAppDriver.sendCommand(`/element/${elementId}/size`, 'GET');
absoluteX = left + Math.trunc(width / 2);
absoluteY = top + Math.trunc(height / 2);
} else {
// coordinates relative to the element's left top corner have been provided
absoluteX += left;
absoluteY += top;

If you have an idea to get a proper coordinate programmatically, we could add such a calculation in this driver layer from the WAD response.
Not the element id, but for example x/y addresses:

The screen scale (if customized) is not taken into consideration while calculating the coordinate.

https://github.com/appium/appium-windows-driver?tab=readme-ov-file#windows-click

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants