Page 1 of 1

can't press button in WPF application

Posted: Thu Jan 12, 2012 9:45 am
by Koen
Ranorex 2.3

I want to press a button within a wpf application but it fails. Below the code and the error.
This code works on a normal windows form ( ex.calculator ).
What is wrong here ?

Code: Select all

 Form form = Host.Local.FindChild<Ranorex.Form>("'^Version:\\ 11\\.45\\.4391\\.36066']");
            form.Activate();
            Button button = form.FindChild<Ranorex.Button>("Button2");
            button.Click();

Code: Select all

 Test Failed Ranorex.CapabilityNotSupportedException: The element does not support the required capability 'button'.
Thanks,
Koen

Re: can't press button in WPF application

Posted: Thu Jan 12, 2012 11:05 am
by Support Team
Hi,

Are you sure that the element you are trying to click on is button? - It seems to be another element, no button.

Please try to track the element with Ranorex Spy to get out the type of the element.
But you can also cast it to Ranorex.Unknown and click on it.

The best way would be to use the element with Ranorex Repository instead of using a hard coded path.
To do this, also check out the documention of using repository in your user code.

Regards,
Martin
Ranorex Support Team

Re: can't press button in WPF application

Posted: Fri Jan 13, 2012 7:01 am
by sham526
Just Try like this

ranorex.unknown btn = home.Findsingle<unknown>("./Button2");
btn.click();

Re: can't press button in WPF application

Posted: Fri Jan 13, 2012 10:55 pm
by Koen
THE element I was trying to click was a text.
Thanks for THE feedback