You can pass the position and size to the application under test by supplying a STARTUPINFO structure to CreateProcess. Now, of course, your problem is to get that STARTUPINFO
structure to CreateProcess
. I don't know how your Launch
method is implemented, but at some point it's going to call either CreateProcess
(good; all you have to do is initialize the STARTUPINFO
structure appropriately) or ShellExecute
(bad, because you can't specify a STARTUPINFO
structure).
How to resize UIA window for UIAutomation purposes, using C#?
-
04-06-2022 - |
Question
I created some coded UI tests for a Win32 application with Visual Studio. I would like the window size to stay consistent so I want it to resize the application window after I launch the application.
I am launching the application like this:
using (ApplicationUnderTest.Launch(this.UIMap.launchReaderParams.ExePath,
this.UIMap.launchReaderParams.AlternateExePath))
{
I have looked into possible ways of doing this and found a method called SetWindowPos()
. However I am unsure of how to use this because it requires the window handle as one of its parameters. How could I obtain the window handle?
Also, is there a better way to resize my application window?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow