Runtime identification of type of control

Ask general questions here.
sivakumaran
Posts: 20
Joined: Fri Dec 18, 2015 8:07 am

Runtime identification of type of control

Post by sivakumaran » Wed Apr 20, 2016 6:09 am

Hello Ranorex team,

I want to write a user code, the intention of the code is, given an rxPath and the value, the code must find the control and set the value.
the control can be a text box, combobox, list box, what not.
so I have to determine the type of the control in the runtime and invoke to according api to set the value for that control.

the rxPath looks like this,
"/form[@controlname='ApplicationFrame']/container[@caption~'^HierarchyFrame:\ Siemens\.A' and @controltypename='HierarchyFrameControl']/container[@controlname='EditorMainFrame']/?/?/container[@controlname='Siemens.Energy.Digsi.FunctionSettings.View.EditorPageFrame']/container[@controlname='Siemens.Energy.Digsi.FunctionSettings.View.SettingsView']//container[@controlname='m_DomainObjectControl']//container[@caption='Definite-T 1']/?/?/combobox[@controlname='0|0|']";

the code looks like this,

public void SetValue(string path, string value)
{
1. Accessible accessible = repo.ApplicationFrame.ModeChangeValueInfo.CreateAdapter<Accessible>(false);
2. AccessibleRole role = Accessible.FromPath(path).Role;
3. Accessible accessible1 = Accessible.FromPath(path);
4. switch(role)
5. {
6. case AccessibleRole.Text:
7. Text text = accessible1.As<Text>();

I want to find the role from the path. Then I want to create a Accessible adapter from the path.
based on the role, I would cast the Accessible adapter to the relevant adapter and do the necessary things to set the value.
The code in line 1 is not relevant to the logic of the method. But without the first line, line 2 throws an exception.
My wish is, the code has to work without the first line like this
2. AccessibleRole role = Accessible.FromPath(path).Role;
3. Accessible accessible1 = Accessible.FromPath(path);
4. switch(role)
5. {
6. case AccessibleRole.Text:
7. Text text = accessible1.As<Text>();

But it is not working so. Please advise as what is missing to make it work.

Regards,
Siva

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

Re: Runtime identification of type of control

Post by Support Team » Mon Apr 25, 2016 1:29 pm

Hi Siva,

I’d like to discuss your intention personally. Therefore, please send an email to [email protected]. Afterwards we will clarify the additional steps.

Thank you for your understanding.

Regards,
Markus (S)