can't press button in WPF application

Class library usage, coding and language questions.
Koen
Posts: 2
Joined: Thu Jan 12, 2012 9:38 am

can't press button in WPF application

Post by Koen » Thu Jan 12, 2012 9:45 am

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: can't press button in WPF application

Post by Support Team » Thu Jan 12, 2012 11:05 am

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
.
Image

sham526
Posts: 34
Joined: Wed Jul 07, 2010 7:12 am
Location: Hyderabad(INDIA)

Re: can't press button in WPF application

Post by sham526 » Fri Jan 13, 2012 7:01 am

Just Try like this

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

Koen
Posts: 2
Joined: Thu Jan 12, 2012 9:38 am

Re: can't press button in WPF application

Post by Koen » Fri Jan 13, 2012 10:55 pm

THE element I was trying to click was a text.
Thanks for THE feedback