question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WinAppDriver does not work with WinForms applications

See original GitHub issue

Hi,

I was trying to use WinAppDriver for a WinForms application. Before release 0.7 the test code was hanging on the line where the session was created. With release 0.7 a session for WinForms application is created (previously it was hanging on that line).

However, now I have a problem with selecting an element. I have a simple WinForms app with a TextBox called textBox1, but neither session.FindElementById nor session.FindElementByName methods are not able to find that element:

System.InvalidOperationException: An element could not be located on the page using the given search parameters.

The PageSource property of the session contains this fragment

<Edit AcceleratorKey="" AccessKey="" AutomationId="textBox1"
 ClassName="WindowsForms10.EDIT.app.0.2bf8098_r9_ad1" FrameworkId="WinForm" 
 HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True"
 IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False"
 IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="edit"
 Name="" Orientation="None" ProcessId="13860" RuntimeId="42.331658"
 x="151" y="158" width="100" height="20" />

The element can be located using FindElementByTagName method.

I have also created a test for WPF application and it works there. I noticed that elements in WPF app do have Name and do not have AutomationId (at least in the PageSource XML document):

<MenuItem AcceleratorKey="" AccessKey="Alt+F" AutomationId="" ClassName="MenuItem"
 FrameworkId="WPF" HasKeyboardFocus="False" HelpText=""
 IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True"
 IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType=""
 LocalizedControlType="menu item" Name="File" Orientation="None" ProcessId="27144"
 RuntimeId="7.27144.34576242" x="138" y="161" width="33" height="21"
 ExpandCollapseState="Collapsed" IsAvailable="True" />

I have put together a project for reproduction https://github.com/kfrajtak/UITesting (you’ll have to change the hard-coded paths).

This issue was created from the discussion for issue #83.

Thanks, Karel

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kfrajtakcommented, Dec 16, 2016

Nice summary @ianceicys!

0reactions
NadeemBadercommented, Sep 12, 2020

Hi I’m facing some issues with WinAppDriver and WinForms. I’m not able to set the value of he following values from the application side, and as a result:

<Edit AcceleratorKey=“” AccessKey=“” AutomationId=“textBox1” ClassName=“WindowsForms10.EDIT.app.0.2bf8098_r9_ad1” FrameworkId=“WinForm” HasKeyboardFocus=“False” HelpText=“” IsContentElement=“True” IsControlElement=“True” IsEnabled=“True” IsKeyboardFocusable=“True” IsOffscreen=“False” IsPassword=“False” IsRequiredForForm=“False” ItemStatus=“” ItemType=“” LocalizedControlType=“edit” Name=“” Orientation=“None” ProcessId=“13860” RuntimeId=“42.331658” x=“151” y=“158” width=“100” height=“20” />

Any suggestions?

Best Regards, Nadeem Bader

Read more comments on GitHub >

github_iconTop Results From Across the Web

WinAppDriver not able to work with winform Application #734
WinAppDriver not able to work with winform Application. We are using WinAppDriver version 1.1 which fails to identify objects on Winforms ...
Read more >
Drag and drop in WinAppDriver doesn't work
Found the answer. WinAppDriver doesn't move the mouse, but "teleport" it. It means mouse cursor is not dragged all the way to the...
Read more >
How To Automate Desktops Apps Using WinAppDriver
This blog deep dives by telling you How To Automate Desktops Apps Using WinAppDriver. It also leverages WinAppDriver on HyperExecute Cloud ...
Read more >
WinAppDriver and Desktop UI Test Automation
In this article I will describe broadly the technical highlights of how Desktop UI automation is done and I will describe the main...
Read more >
Windows Desktop Application Test Automation with ...
WinAppDriver supports testing Universal Windows Platform (UWP), Windows Forms (WinForms), Windows Presentation Foundation (WPF), and Classic ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found