WinAppDriver does not work with WinForms applications
See original GitHub issueHi,
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:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Nice summary @ianceicys!
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