-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Move mouse to any point on screen with WinAppDriver #810
Comments
If it is a windows form calibrate the screen. My guess is that you can get the scaling information that you need from their positions |
@DLightstone my app is WPF one. Of course, it has the title bar with default buttons (minimize/maximize & close buttons). However, i don't really catch your idea with getting scaling information from their positions. |
I do not know the reference for the position and size information provided by attribute retrieval. I have assumed them to be actual screen coordinates. I assumed move offset to be in actual screen coordinates rather than relative to the current application window. I assumed that the positioning was to move was for purposes of either activating an application control located at that position or editing a pixel at that location. It became a question of - To position to a particular application pixel what absolute screen pixel is needed? That is a scaling problem. I just wanted to get the locations of 2 application points (minimize button and maximize button were the first points I thought about. I completely forgot you could get the window size) At start up of the program under test, maximize the screen (one time event), get the display screen size. It may be possible to get the display size via other means. At any other time the then current application window size. The 2 measurements give you the scaling info for the application window relative to the display screen. |
I see what you mean. So you will use the screen at maximum size to measure the screen. It's a good idea because it least, i have to do it one time only. The other point is the method |
There probably is a better means for measuring the screen. A user can change the resolution of the screen, so the selected resolution must be saved in the registry somewhere. That is probably what you will retrieve when you measure the screen by maximizing it. The mouse is a device, it generates events. There probably is a mechanism by which you can subscribe to receive those events. How that mechanism might work I do not know, but I would be very much surprised if one does not exist. see |
I know we can get the mouse. The issue is how we get it from Appium. My scenario is: |
Generally I try to do as much testing as possible on a local machine. Don't get the mouse position from the application under test. Using Appium with the second application may just be a convenience (no need to make the second application a server). The application should have a form with text boxes for the mouse information that you want. Appium can retrieve from those text boxes If you can't have such an application installed then you are testing on a production server, and should not be doing so. |
Hi @khoachung89 |
Hi @HenryColes I used next c# code to click by coordinates with WinappDriver: var element = session.FindElement(By...);
new Actions(session).MoveToElement(element, 0, 0).MoveByOffset(dx, dy).Click().Build().Perform(); To reset the mouse coordinates use this: |
I have automation test that run on client and WinAppDriver with my tested app on server.
With the session created from capability 'app' = 'root'
var option = new AppiumOptions();
option.AddAdditionalCapability("app", "Root");
var session = new WinAppDriverSession<T>(new Uri(serviceUrl), option);
Now i want to move the mouse to a point on screen - even that point is out of my app's window. Up to now, i have to do 2 steps:
move mouse to top left of screen with
-int.MaxValue
- looks ugly:Actions a = new Actions(session);
a.MoveByOffset(-int.MaxValue, -int.MaxValue);
a.Perform();
move mouse to the desire point:
a = new Actions(session);
a.MoveByOffset(myPoint.X, myPoint.Y);
a.Perform();
Because at the client, i have no idea how to get remote screen resolution or current mouse position. I cannot move the mouse to desire point with one action. Is there any better solution to get the same result? In my real scenario when i have thousands of automation test cases, the mouse move to top left of screen lot of times and looks silly.
Many thanks,
The text was updated successfully, but these errors were encountered: