Page 1 of 1

Use variable in C# script

Posted: Mon May 23, 2016 10:18 am
by romainb25
Hi community,

I have a recording called "TestCase1" linked to and Excel File by an Excel Data Connector called "TestCase1.xls"
I create three variables in test case : name ,hasPhoneNumber and phoneNumber

There is the xls view :
id | name | hasPhoneNumber | phoneNumber
1| romain | yes | 0606060606
2 | paul | no |
3 | jacques | yes | 0505050505

In my script, i would like to have the same code as this:
for(i=1,i<3,i++)
{
if(hasPhoneNumber = "yes")
{
getPhoneNumber();
}
else if(hasPhoneNumber = "no")
{
text : No phone number for this people!
}
}

Can i use a variable and get his value in a C# script?

Thanks

Re: Use variable in C# script

Posted: Mon May 23, 2016 11:15 am
by odklizec
Hi,

Are you using code module or recording module?

In case of Code Module, you will have to create variable "hasPhoneNumber", via context (right-click) menu >> Insert New Module Variable option. Then simply connect the variable with data connector.

If you are using Recording Module, you can create new variable (in UserCode file) via Variables dialog.

Re: Use variable in C# script

Posted: Tue May 24, 2016 11:29 am
by romainb25
Thanks @odklizec : it works!