-
Notifications
You must be signed in to change notification settings - Fork 58
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
UI automation #47
Comments
Thanks for opening this issue @agowa338. |
This issue has been open for 30 days with no updates. |
2 similar comments
This issue has been open for 30 days with no updates. |
This issue has been open for 30 days with no updates. |
Still waiting.... |
This issue has been open for 30 days with no updates. |
Microsoft team, please provide an update. |
From the replies this got I think some clarification is needed. I also think I now understand what @vrapolinario meant with there already being an official way. There is: https://docs.microsoft.com/en-us/dotnet/framework/ui-automation That API is not able to fake input to notepad without the window being onscreen and having focus. But there are also advantages of the current API. For example compared to AutoIt it allows to access elements within an WPF element within an dotnet application. And it doesn't require an additional runtime, powershell/dotnet is enough Tl;Dr: The current state is better than I initially was aware of, but it still needs some polishing. Example code for automating notepad: [void][System.Reflection.Assembly]::LoadWithPartialName("UIAutomationClient")
[void][System.Reflection.Assembly]::LoadWithPartialName("UIAutomationTypes")
[void][System.Reflection.Assembly]::LoadWithPartialName("UIAutomationProvider")
[void][System.Reflection.Assembly]::LoadWithPartialName("UIAutomationClientsideProviders")
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
# According to the documentation this should be also called, but within powershell 7.1 it fails
# and within Windows Powershell (5.1) it is unstable and always throws an exception the first time it is called and succeeds the 2nd time...
# Also it doesn't seam to be needed for "just" automating notepad.
#$client = [System.Reflection.Assembly]::LoadWithPartialName("UIAutomationClientsideProviders")
#[Windows.Automation.ClientSettings]::RegisterClientSideProviderAssembly($client.GetName())
$autProc = Start-Process notepad -PassThru
$rootElement = [Windows.Automation.AutomationElement]::RootElement
$condAUTProc = [Windows.Automation.PropertyCondition]::new([Windows.Automation.AutomationElement]::ProcessIdProperty, $autProc.Id)
$autElement = $rootElement.FindFirst([Windows.Automation.TreeScope]::Children, $condAUTProc)
# LocalizedControlTypeProperty is derived using "Accessibility Insights for Windows"
$documentElement = [Windows.Automation.PropertyCondition]::new([Windows.Automation.AutomationElement]::LocalizedControlTypeProperty, "document")
$document = $autElement.FindFirst([Windows.Automation.TreeScope]::Descendants, $documentElement)
$document.SetFocus()
[System.Windows.Forms.SendKeys]::SendWait("FooBar") |
Does |
There's an issue on that repo: microsoft/WinAppDriver#1046 covering exactly that. While that tool appears not to work on Windows Containers as it depends on an active desktop session, there are alternatives in there. I went ahead and opened an issue on their repo to add support for Windows Containers. Please remember this is a different team and we don't own their prioritization. We'll definitely work together if needed, though. |
The general issue with UI automation is that
Also, for such apps state monitoring like an ability to take a screenshot would be really useful. |
UI automation appears to not work at all when I try using windows:1909 and TestStack.White. After opening notepad.exe and using the underlying System.Windows.Automation, I don't see any children under the root element (Desktop). IE, the following prints nothing: using System.Windows.Automation;
...
var lWalker = new TreeWalker( Condition.TrueCondition );
var lElement = lWalker.GetFirstChild( AutomationElement.RootElement );
while ( lElement != null )
{
Console.Out.WriteLine( $"{lElement.GetType().Name} {lElement.Current.Name} {lElement.Current.ProcessId} {lElement.Current.BoundingRectangle}" );
lElement = lWalker.GetNextSibling( lElement );
} |
The What we could really use is a way to run multiple copies of Windows Sandbox as part of our CI. Why can't we use that as a Docker base? That also doesn't require a 6GB download/17GB image. |
The team apparently doesn't accept feedback. There isn't "provide feedback" at the bottom of the page as other docs pages have... |
Than can I recommend you provide the feedback directly at their repo? Here's the URL: https://github.com/microsoft/dotnet. |
This issue has been open for 30 days with no updates. |
Is it right that UI automation of legacy apps for Windows Containers infrastructure is not a priority for dev team right now? |
We made some progress on this with the Windows image that has a larger set of APIs available. Other than that, it seems the request is for tools that perform automation of UI tests need to support its own deployment on Windows containers. This unfortunately is out of our scope on the platform. |
@vrapolinario There appears to be negative progress on the Windows image that had a larger set of APIs available. From reading here, things that used to work in 1809 containers (like getting the main window title) no longer work in 1909 containers. What we could really use is containers based on Windows Sandbox. But Microsoft puts artificial restrictions on that (along with the artificial licensing restrictions on normal Windows sessions) that makes it very very difficult to perform Windows Desktop UI automated testing. |
Adding @weijuans-msft for visibility. |
@vrapolinario re large set of APIs, is it now possible to take a screenshot of a running app in a Windows Container? If not, when will it be available? |
I'm not aware of a PowerShell option (or cmd for that matter) to take a screenshot, so I'm assuming it's not possible. |
Folks, after some internal investigation I'm getting the conclusion that we don't have a better answer at this point on UI automation, other than the APIs we provide on the Windows image. Since this seems to be a hot topic, I wanted to comment here and let you know that this is something we're taking in consideration as we evaluate new capabilities for Windows containers. Thanks for your input so far. We'll close this issue for now, but please rest assured the inputs from this thread will feed our investments on upcoming releases. |
Thanks for this. Please let us know if there is any roadmap |
With the release of this new image, are there any changes with respect to this topic? |
update? |
Hi @vrapolinario, any update on this? it's been 6+ months since you were last active in this thread. |
Hey everyone, the Windows containers product team is still monitoring this issue. I am reopening the issue to keep for tracking the feature request, but there are no new updates to provide--it is still sitting on our backlog. If/when we do have an update, we will post it here or you can monitor the Windows container blog. |
This issue has been open for 90 days with no updates. |
Up |
At this time, we don't have any plan to support. Close it for now. Can reopen if this is changed. |
@weijuans-msft, with all the respect it's not completed, it is failed. |
Can you offer an explanation as to why this use case is not supported? Its literally one of the most useful features of containers. UI testing is a giant chore using VMs. Clearly all the code to make it work already exists (e.g. windows sandbox) and this is a totally artificial software imposed limit. |
Support UI (and UI automation) the windows ecosystem sadly is often "UI first" when it comes to software design. And the powershell/command line interfaces are not available or not documented at all. It would be great for sysadmins to be able to encapsulate these applications in containers, so that they are no longer bound to a single host and can be put into a k8s cluster without requiring something developers and Ranorex and a lot of time.
The text was updated successfully, but these errors were encountered: