How to get Test variable through custom code in HP UFT - ApiTest

0
0

I want to set value to the Test Variable using Custom Code.
Can you tell me how to do it as i am not able to access the variable from code.

UFT profile variable

I need to access the User Variable URL in my custom code and set the value.

Please help me if you know how to do it using Custom Code.

Thanks,
Madhan

  • You must to post comments
0
0

Based on your question:

1. Click on File menu and then Settings, it will open Properties pane.

2. Click on “+” to add user variable and give a name.

3. In your custom code, type below code:

  string s = "https://www.google.com/";
this.Context.TestProfile.SetVariableValue("NameOfYourVariable",s);

To retrieve the value of given variable:

  string ss = this.Context.TestProfile.GetVariableValue("NameOfYourVariable");
CodeActivity5.Report("Variable is : ", ss); //(This line will print your variable value)
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website