Devexpress SimpleButton

Ask general questions here.
a_kor
Posts: 3
Joined: Wed Sep 09, 2009 1:38 pm

Devexpress SimpleButton

Post by a_kor » Wed Sep 09, 2009 1:50 pm

Is there a way to find a Devexpress SimpleButton on the form?

/*
Form form = Host.Local.FindChild<Ranorex.Form>("Myform");
form.Activate();

Button button = form.FindChild<Ranorex.Button>("btnMyButton"); // DevExpress control.
button.Click();
*/
It does not work. Would you give me some ideas how to sort it out, please?

thank you very much )

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Devexpress SimpleButton

Post by Support Team » Wed Sep 09, 2009 2:23 pm

What "does not work"? Could you please explain the issue a little more in detail?
Have you tried using the Ranorex Recorder?

Please, check that the DevExpress control really has the Button capability, otherwise you can't assign it to a Button adapter. Please, read the following user guide chapter for more info:
http://www.ranorex.com/support/user-gui ... apter.html

Regards,
Alex
Ranorex Support Team

a_kor
Posts: 3
Joined: Wed Sep 09, 2009 1:38 pm

Re: Devexpress SimpleButton

Post by a_kor » Wed Sep 09, 2009 2:53 pm

No I have not used the recorder. The problem is that the DevExpresse SimpleButton can not be found by Ranorex on the loaded form and I can't invoke Click event of that control. I use .Net 3.5 VS 2008.

a_kor
Posts: 3
Joined: Wed Sep 09, 2009 1:38 pm

Re: Devexpress SimpleButton

Post by a_kor » Wed Sep 09, 2009 3:07 pm

thanks Alex, the link was a great help. It works now.

vtp
Posts: 7
Joined: Wed Sep 16, 2009 4:39 pm

Use of *only* button "controlname" possible?

Post by vtp » Wed Sep 16, 2009 5:07 pm

When I use the ranorex recorder I get a path to the (DevExpress?) element "SimpleButton" button like

"/form[@controlname='UserSelectionForm2']/container/element[@controlname='okButton']/button[@accessiblename='OK']"

So I tried something like the following code and it works:
string rxpathLoginForm = "/form[@controlname='UserSelectionForm2']";
Ranorex.Button loginOk1 = rxpathLoginForm + "/container/element[@controlname='okButton']/button[@accessiblename='OK']";


But now I don't want to use the accessiblename attribute, because I have the button name and I don't know the text at the button if the application is started in another language.
So I tried something like
string rxpathLoginForm = "/form[@controlname='UserSelectionForm2']";
Ranorex.Button loginOk1 = rxpathLoginForm + "/container/element[@controlname='okButton']";
and this don't work.

How must I use the Ranorex path correct, that I work *only* with the button name and *not* with the (language depending) text of the button?

Thank you for your help!

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Devexpress SimpleButton

Post by Ciege » Wed Sep 16, 2009 5:16 pm

Just for sanity sake make sure there is only one button below the element "'okButton'". There should be...

Anyway, try changing your xPath to:

Code: Select all

Ranorex.Button loginOk1 = rxpathLoginForm + "/container/element[@controlname='okButton']/button";
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Devexpress SimpleButton

Post by Support Team » Thu Sep 17, 2009 7:42 am

Or you could directly assign your path to a Ranorex.Control adapter if you want to use that adapter anyway:
Ranorex.Control loginOk1 = rxpathLoginForm + "/container/element[@controlname='okButton']";
Assigning this path to a Button adapter does not work, because the element with ControlName 'okButton' is not identified as a button (it does not have the Button capability, e.g. when tracking the element in Ranorex Spy).

Just for clarity, there are two main reasons that assigning a path to a Ranorex adapter does not work:
  1. The RanoreXPath is not found, you get an ElementNotFoundException --> be sure to use the right path copied from Ranorex Spy and that the search timeout is high enough
  2. The element found does not support the capability of the adapter you assigning it to, you get a CapabilityNotSupportedException --> be sure to use an adapter that is listed in the 'General' tab of Ranorex Spy when you tracked the element
Regards,
Alex
Ranorex Support Team

vtp
Posts: 7
Joined: Wed Sep 16, 2009 4:39 pm

Re: Devexpress SimpleButton

Post by vtp » Thu Sep 17, 2009 10:39 am

Thank you for your help! Both solutions work good.

But there are two more questions now:
@Ciege:
What do you mean with
"Just for sanity sake make sure there is only one button below the element "'okButton'". There should be..."?
When I use the controlname can there be two buttons with the same name?

@Alex:
Now I think a part of my problem was also the container or element attribute, because
Ranorex.Button loginOk1 = rxpathLoginForm + "/container/button[@controlname='okButton']";
also doesn't work.

At http://www.ranorex.com/support/user-gui ... xpath.html or http://www.ranorex.com/support/user-gui ... mples.html I can only found something like Button myButton = "/form[@title='Calculator']/button[@text='5']"; but my button seems not to be direct at the form, but on the container or element.

So, where can I learn more about container or element (or /container/elemet)?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Devexpress SimpleButton

Post by Support Team » Thu Sep 17, 2009 12:31 pm

vtp wrote:Now I think a part of my problem was also the container or element attribute, because
Ranorex.Button loginOk1 = rxpathLoginForm + "/container/button[@controlname='okButton']";
also doesn't work.
I think you have not yet fully understood the concept of Ranorex capabilities/adapters. Just because you (a human being) identify a control as a button, there is no guarantee that Ranorex will also identify that control as a button. It seems that Ranorex does not recognize your control as a button, that's why it's reported as a plain element and not as a button. So, when you track that element using Ranorex Spy, it won't have the Button capability, i.e. you can't access it as a Button through Ranorex (it should have the Control capability, though, since it's a .NET Control). Please, have a look at the following topic in the Ranorex User Guide:
http://www.ranorex.com/support/user-gui ... apter.html
vtp wrote:When I use the controlname can there be two buttons with the same name?
Yes, there can be more controls with the same ControlName, because it's just the value you assign to the System.Windows.Forms.Control.Name property. However, by default, the Visual Studio designer makes sure that control names are unique, because it uses the same names as variables.

Regards,
Alex
Ranorex Support Team

vtp
Posts: 7
Joined: Wed Sep 16, 2009 4:39 pm

Re: Devexpress SimpleButton

Post by vtp » Thu Sep 17, 2009 2:42 pm

Thank you for your explainings. Now I hope I understand what happens.

Code: Select all

Ranorex.Button loginOk1 = rxpathLoginForm + "/container/button[@controlname='okButton']";  // 1. don't work
Ranorex.Control loginOk1 = rxpathLoginForm + "/container/element[@controlname='okButton']"; // 2. work
 
The 1. don't work because Ranorex does not recognize it as a button and
the 2. work beause it works for every .Net control.


So I thought Ranorex Spy will gives me something like "/form[@title='Calculator']/element[@text='5']" when Ranorex Spy can't recognize it as a button.

But that ("hand made") Ranorex XPath with ".../element..." works not with
Ranorex.Control control = "/form[@title='Calculator']/element[@text='5']";
and I get "Ranorex.ElementNotFoundException: No element found for path '/form[@title='Calculator']/element[@text='5']' ...".

I'm sorry when I ask again where I can learn more about that "...\element..." in a Ranorex XPath, but I can't find something about that at your given URL.

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Devexpress SimpleButton

Post by Ciege » Thu Sep 17, 2009 4:16 pm

vtp wrote:@Ciege:
What do you mean with
"Just for sanity sake make sure there is only one button below the element "'okButton'". There should be..."?
When I use the controlname can there be two buttons with the same name?
As Alex said there can be an instance where 2 buttons (or any object for that matter) may exist with the same name at the same time. Not ideal for automation but does happen. When this happens Ranorex will (usually) identify each object uniquely with an index number (in order they are discovered on the form). The downside is if the form design is changed and you have referenced index #2, it may become index #1 without you knowing and your path to the object you want is no longer valid. If you ever run into this scenario then you need to ask your dev team (bring donuts and candy) to uniquely name the objects if at all possible.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Devexpress SimpleButton

Post by Support Team » Thu Sep 17, 2009 5:16 pm

"element" in a RanoreXPath is only valid if the element has the Element capability/role (that's usually the case if no other role is applicable or the element is just not recognized by Ranorex). The Element capability is just not shown in the "General" tab of Ranorex Spy, because it does not provide any attributes.
If you want to identify elements without specifying a capability in a RanoreXPath, use the '*' character:
Ranorex.Control loginOk1 = rxpathLoginForm + "/container/*[@controlname='okButton']";
This RanoreXPath will find an element which ControlName is 'okButton' without checking its capabilities (nevertheless it will have the Control capability, because the ControlName attribute is defined by that capability).

Regards,
Alex
Ranorex Support Team

vtp
Posts: 7
Joined: Wed Sep 16, 2009 4:39 pm

Re: Devexpress SimpleButton

Post by vtp » Fri Sep 18, 2009 3:39 pm

Thanks to Ciege for your explanations. There are a point of view I've not really thought about till now, but I think it is importent to know.

Also Thanks to Alex for your explanations. Your code snippet works fine and I see how it works.


Unfortunately I have still the asking where I can learn more about these things how a Ranorex XPath can be build. The only site I've found with informations about the Ranorex XPath is http://www.ranorex.com/support/user-gui ... xpath.html.But I've found no site where I can get these informations about the '*' character in the meaning you've told me for example. I think there are certain more of informations like these which are good to know when you use Ranorex XPath.

So if you have a site for me I will be pleased about that and I can get a better understanding about all the possibilities in/at a Ranorex XPath.

And also a question to the adapters. Is there a "master" adapter where I can work with all elements (like object in c# for int, string, ...)?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Devexpress SimpleButton

Post by Support Team » Mon Sep 21, 2009 11:10 am

You are right, the RanoreXPath documentation in the Ranorex User Guide is not complete, we are going to extend the documentation and add some general explanation to the individual parts of a RanoreXPath. Meanwhile, as RanoreXPath is inspired by W3C XPath, please consult XPath related documentation, e.g. on the W3C web site: http://www.w3.org/TR/xpath.

The Unknown adapters can be used with any element. I.e. you can assign any element to an Unknown adapter, since this adapters does not require any capabilities.

Regards,
Alex
Ranorex Support Team