Object referenceing

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
ltambeau
Posts: 2
Joined: Fri Jun 22, 2012 4:54 pm

Object referenceing

Post by ltambeau » Fri Jun 22, 2012 5:08 pm

I want to be able to send an object description to a utility function that allows me to perform an action on the object I sent

Simple CSHARP Example:
//***** Set variable foo to object to be referenced
var foo = repo.FormNMS_b4_1_0_15.ContainerContainerContainer.TabPageNode_List;
foo.click(); //***** Action performed on the object

Is there a casting I can do?

Can I define the variable as a particular type?

tried:
var foo = (Rxpath) repo.FormNMS_b4_1_0_15.ContainerContainerContainer.TabPageNode_List;

var foo = (Ranorex.TabPage) repo.FormNMS_b4_1_0_15.ContainerContainerContainer.TabPageNode_List;

Ranorex.Tabbpage foo = repo.FormNMS_b4_1_0_15.ContainerContainerContainer.TabPageNode_List;

var foo = (Ranorex.Core.Repository.RepositoryEntry)
repo.FormAmbientNMS_b4_1_0_15.ContainerContainerContainer.TabPageAmbient_Node_List;

RxPath foo = "repo.FormAmbientNMS_b4_1_0_15.ContainerContainerContainer.TabPageAmbient_Node_List";

var foo = (Ranorex.Core.Repository.RepositoryItem)
repo.FormAmbientNMS_b4_1_0_15.ContainerContainerContainer.TabPageAmbient_Node_List;

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

Re: Object referenceing

Post by Support Team » Mon Jun 25, 2012 3:43 pm

Hi,

Sorry but I am not sure if I completely got your question.
You can of course define a variable as a particular type, you just have to make sure that you are using the right one.
For instance if your repo item "is" a checkbox you can create a new CheckBox variable like:
Ranorex.CheckBox checkBox = repo.Calculator.CheckBox146;
checkBox.Click();
      // OR
var checkBox1 = repo.Calculator.CheckBox146;
checkBox1.Click();
Regards,
Markus
Ranorex Support Team
.
Image

ltambeau
Posts: 2
Joined: Fri Jun 22, 2012 4:54 pm

Re: Object referenceing

Post by ltambeau » Mon Jun 25, 2012 3:59 pm

Almost there ... looking for further abstraction. Want to set up a function call objClick((casting) itemToClick) where the itemToClick is any valid object that can be clicked (Into a textbox, a button, a treeitem) and the casting is some sort of neutral definition (like object or RxPath). If I must identify each object by its specific type (Ranorex.Checkbox) then I lose the abstraction and would likely stick with the "repo" id (repo.container.myCheckbox).

Lee

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

Re: Object referenceing

Post by Support Team » Mon Jun 25, 2012 4:19 pm

Hi,

Okay now I got it ;).
You can for instance use the following definition of a method:
...
      generalMethod(repo.Calculator.CheckBox146);
}
    
public void generalMethod(Adapter adapter){
      adapter.Click();
    }
I hope this will help solve the issue!

Regards,
Markus
Ranorex Support Team
.
Image