WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

WinAppDriver does not work with WPF/WinForms applications

Open QuantumDeveloper opened this issue 10 years ago • 26 comments

DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", @"C:\myWPFApp.exe"); NotepadSession = new IOSDriver<IOSElement>(new Uri(AppDriverUrl), appCapabilities);

On the third line it starts my app and just hangs. But with Native Win32/UWP applications driver creates correctly and quickly.

Is there a way to prevent driver from hanging when starting WPF/WinForm applications?

QuantumDeveloper avatar Oct 28 '16 13:10 QuantumDeveloper

I've reproduced the bug. Thanks for filing this. We're investigating.

yodurr avatar Oct 31 '16 17:10 yodurr

Is there any update on the WPF/Winforms issue?

Greeny99 avatar Nov 14 '16 09:11 Greeny99

We have a fix implemented that will be available in the next release

timotiusmargo avatar Nov 14 '16 18:11 timotiusmargo

Is there a nightly drop that we can use until you guys get the next release rolling? I'd really like to start adapting this, but the wpf/winforms issue is a huge blocker.

ivan-prodanov avatar Nov 17 '16 15:11 ivan-prodanov

When you guys are releasing new build?

rahul24 avatar Nov 17 '16 17:11 rahul24

Is there a fix or a workaround for this issue?

nitroxn avatar Nov 24 '16 04:11 nitroxn

This is not a workaround... I suggest nightly build drops to be provided as well. Yes, it's beta and all but having these beta versions plus nightly builds gives me and my team the benefit to integrate this thing faster within our organization. This might lead to more issues, which is not necessarily a bad thing. Nevertheless, blockers like this issue will be fixed and delivered much faster. Nightly builds => more immediate feedback => less blockers => more users => stronger community => even more feedback => better quality.

ivan-prodanov avatar Nov 26 '16 08:11 ivan-prodanov

Please let us know when can we expect the fix for wpf applications (as winappdriver doesnt work for wpf app currently) . Today is Nov 30, was expecting the new release today. Please provide us the fix ASAP as this is blocker for us

vijayalakshmi-ml avatar Nov 30 '16 16:11 vijayalakshmi-ml

I would also like to know when we can expect a fix for this or a workaround so we can start experimenting.

SimonKirkhamCL4U avatar Nov 30 '16 16:11 SimonKirkhamCL4U

Thanks for your patience. We're trying to get a release out by EOD today.

yodurr avatar Nov 30 '16 21:11 yodurr

@yodurr Just saw the release, but it states WPF only. What about WinForms? Is this going to be supported?

ivan-prodanov avatar Dec 01 '16 01:12 ivan-prodanov

Yes WinForms support is included. We'd really appreciate if you can try 0.7 and please file a bug if it isn't working for you. Thanks!

yodurr avatar Dec 01 '16 01:12 yodurr

Hi @yodurr, thanks for the release, 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.

Thanks for the help (maybe I'm missing something basic).

Karel

kfrajtak avatar Dec 01 '16 09:12 kfrajtak

Working for me now (sometimes but I think that is due to the app under test).

SimonKirkhamCL4U avatar Dec 01 '16 11:12 SimonKirkhamCL4U

@ianceicys Can you post the fragment of the PageSource XML document?

kfrajtak avatar Dec 01 '16 16:12 kfrajtak

Hi..After using the latest release , my wpf app opens up successfully. But am not able to locate any element using id or classname or name. Am i missing something? Note: Am using Inspect tool to locate the element.

vijayalakshmi-ml avatar Dec 01 '16 18:12 vijayalakshmi-ml

@ianceicys, it works! It works with a session created by using both RemoteWebDrive and IOSDriver<IOSElement> classes.

It still does not work for WinForms app ...

What I noticed is 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" />

If you are willing to give it a try, there's a project I created at https://github.com/kfrajtak/UITesting (you'll have to change the hard-coded paths). Thanks, Karel

kfrajtak avatar Dec 02 '16 17:12 kfrajtak

@kfrajtak . Am also working in WPF app. Some of the elements have 'AutomationId' & some have 'Name'. But when I use AutomationId or Name , it doesn't locate the element. For some reason it fails with element not found exception. Is there any solution or workaround for this issue?

vijayalakshmi-ml avatar Dec 02 '16 18:12 vijayalakshmi-ml

@ianceicys

I tired as you said.

tagname

The field corresponding to LocalizedControlType was "tab item". So I used it as below in my code

Session.FindElementByTagName("tab item").Click();

Still It didnt work. Am i missing something? Please let me know your thoughts

vijayalakshmi-ml avatar Dec 02 '16 20:12 vijayalakshmi-ml

Hi @ianceicys

Am trying to automate the WPF app that we are using in our project. In our application the LocalizedControlType is "tab item". Hence I used Session.FindElementByTagName("tab item").Click();

This didnt work. It isnt able to locate the element

vijayalakshmi-ml avatar Dec 02 '16 21:12 vijayalakshmi-ml