Setting Element Attribute in User Code

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
saad.ayub
Posts: 1
Joined: Wed Dec 11, 2013 5:00 pm

Setting Element Attribute in User Code

Post by saad.ayub » Wed Dec 11, 2013 5:32 pm

Hi All,

A noob question.

I have an element in the ranorex repository which has an attribute set to a variable.
eg:
//Column[@text=$varcolumnname]
This Variable has a default value assigned to it "Ccy" in the repo.

Can someone tell me how i can go about setting this variable to something else in user code?
eg: "Name"

I'm thinking i can use the setattributevalue on the element but not sure what the code should be.

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Setting Element Attribute in User Code

Post by krstcs » Thu Dec 12, 2013 2:50 pm

If you just want to change the value of the variable, you can just assign the variable a new value in user code. It is just a .NET string variable type.

Code: Select all

varcolumnname = "Name";
You have to have declared the variable in the test module you are using it in.

Also, you need to remember that this will set the variable to the new value for all future uses, until the value is set again.
Shortcuts usually aren't...