Re: Accessing GUI Test Action output parameters in API Test custom code. (2495 Views)
Reply
Advisor
iSpy
Posts: 16
Registered: ‎03-22-2013
Message 1 of 9 (2,760 Views)
Accepted Solution

Accessing GUI Test Action output parameters in API Test custom code.

We have an API Test in UFT which in turn calls other UFT GUI Test's reusable actions. These actions have output parameters (e.g. 'Step1_Result', 'Step2_Result' etc.)


Our requirement is to access those UFT GUI test output parameters and use their values in the custom code activity of the API Test in UFT.

 

e.g. string strStatus = this.CallQTPTestActivity33.something

Advisor
citizencrane
Posts: 21
Registered: ‎11-03-2010
Message 2 of 9 (2,747 Views)

Re: Accessing GUI Test Action output parameters in API Test custom code.

drag and drop the GUI component onto the canvas, it should have 2 output parameters associated with the activity. Add the appropriate input parameters to the Custom Code Activity and pass it in.

Corey Bailey
Principal Consultant
Citizencrane Solutions
www.citizencrane.com
Advisor
iSpy
Posts: 16
Registered: ‎03-22-2013
Message 3 of 9 (2,745 Views)

Re: Accessing GUI Test Action output parameters in API Test custom code.

That's basically useful for the Custom Code activities where you can add input and output parameters. What if the GUI Test Action output parameter is to be used in, say, CodeCheckPointEvent_Handler of some standard activity? There you cannot pass the parameter value as input param.

Advisor
citizencrane
Posts: 21
Registered: ‎11-03-2010
Message 4 of 9 (2,741 Views)

Re: Accessing GUI Test Action output parameters in API Test custom code.

Create a Test Variable  in the properties start section

 

Pass in a string from the GUI output to the the test variable ...

 

 

From a custom code activity

this.CodeActivity8.Context.TestProfile.SetVariableValue("TestParam","<value>");

OR

From the activity Event

this.Context.TestProfile.SetVariableValue("TestParam,"<value>");

 

Then from the checkpoint event

this.Context.TestProfile.GetVariableValue("TestParam");

 

This should do the trick.

 

Regards

Corey

 

 

 

 

 

Corey Bailey
Principal Consultant
Citizencrane Solutions
www.citizencrane.com
Advisor
iSpy
Posts: 16
Registered: ‎03-22-2013
Message 5 of 9 (2,733 Views)

Re: Accessing GUI Test Action output parameters in API Test custom code.

Hey Corey,

 

Thanks for the reply.

 

However, in a framework, where number of GUI Tests and the number of reusable Actions therein is unknown previously OR where it may keep changing, having equivalent number of test variables is not really that feasible. I am thinking of a more generalized approach where the CodeCheckPointEvent_Handler can directly access the GUI Test Action output parameter.

 

The approach would take the XPath of the node and convert it to string.

 

Can you develop something around the above idea? :)

 

Best regards,

iSpy

 

P.S.: Taking the challenge further, I am also pondering on how to set the variable value once we have found out how to access it. :)

Advisor
iSpy
Posts: 16
Registered: ‎03-22-2013
Message 6 of 9 (2,710 Views)

Re: Accessing GUI Test Action output parameters in API Test custom code.

There are following two ways to do this:

 

var stepResult = this.CallQTPTest16.OutputArguments.SelectSingleNode("/*[local-name(.)='Arguments'][1]/*[local-name(.)='Param1'][1]").InnerText;

 

or,

 

var stepResult = this.CallQTPTest4.OutputArguments["Arguments"]["Param1"].InnerText;

Occasional Advisor
palam
Posts: 10
Registered: ‎04-10-2013
Message 7 of 9 (2,530 Views)

Re: Accessing GUI Test Action output parameters in API Test custom code.

[ Edited ]

Sorry for opening up the Discussion again - Sorry if this question is repetitive as the above in the same thread - Just to make it things clear

 

I am calling API test from the GUI test 

 

 

 

 scenario is 

Start ->UFT GUI Action1 - No Output Parameter  ->UFT GUI Action 2 - one output parameter->UFT API Test 

 

 

In the API test I have following activities lined up - Open Connection, Data select and Web service method call activities from the toolbox 

 

  1. How to Access the Output parameter of  GUI Action2  in the  UFT API Test (I will be using that parameter as one of the input property for the Web service method 
  2. In the Dataselect - I have a query - I would like use the output parameter value  in the where clause of the SQL query statement

 

Help is very much Appreciated on this - thank you

 

 

 

 

Advisor
iSpy
Posts: 16
Registered: ‎03-22-2013
Message 8 of 9 (2,518 Views)

Re: Accessing GUI Test Action output parameters in API Test custom code.

Hi Palam,

Please find the answers inline:

1.How to Access the Output parameter of GUI Action2 in the UFT API Test (I will be using that parameter as one of the input property for the Web service method

- Link the input parameter of the web service method to the output parameter of the activity which calls your GUI Action2.


2.In the Dataselect - I have a query - I would like use the output parameter value in the where clause of the SQL query statement

- Again, link the parameters.

Write the query in the query builder. Then click on the link icon and in the dialog box that appears, click Custom Expression. A test box will appear below where your query will be visible. Now put the cursor where you want to use the previous activity's output parameter. Select that parameter from the tree above (Click on Available Steps if it is not visible) and then click on Add.


Both the things are pretty easy to do. If you need more assistance on linking of the parameters, please let me know.

Best Regards,
iSpy
Occasional Advisor
palam
Posts: 10
Registered: ‎04-10-2013
Message 9 of 9 (2,495 Views)

Re: Accessing GUI Test Action output parameters in API Test custom code.

[ Edited ]

1.How to Access the Output parameter of GUI Action2 in the UFT API Test (I will be using that parameter as one of the input property for the Web service method

- Link the input parameter of the web service method to the output parameter of the activity which calls your GUI Action2.

 

When We try to link the parameter of the web service method - GUI test is not visible - 

As of now as a work around what i have done is I am writing the required data in the Database - and using the select component of the database to data in the Web service method 

 

No issues on the Second Resolution - thank you very much:)

 

 

I have few more issues 

When i try to call the action of the API test from the GUI test - I get a general run  error - nothing seems to be wrong -I dont have a clue of how to get his resolved.

API test alone is working

 

 

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.