Highlighted
Trusted Contributor.. Trusted Contributor..
Trusted Contributor..
795 views

TruClient: exiting a function() to continue script

Hi there,

I have a fair complex script in TruClient 12.57 to test some features of our site like login, read news, see accountings, do some calculations.  I have one script with several actions() in the action-section in with each action() calling one or more library functions().

I also have some handlers to react on events like cookie-handler (press OK), http-500-handler (browser return) and so on for error handlng.

From time to time under load our calculator doesn't react fast enough so the page shows "app temporarily unavailable". I do have a catch-block for "Object Identification" but how do I exit the function  I'm in without exiting the vUser, the iteration or whole action-section?

I've tried Evaluate JavaScript-Step with "return;" "fail;", exit(Action) ... but they all stop the script or skip to the next iteration.

Isn't there an option to return into the action() to call the next function() or next step in an action?

Thanks for yout advices

0 Likes
4 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: TruClient: exiting a function() to continue script

Hi @PascalCalovini,

There is an option to control what to do when an error happens. The option is "Action on error", available options are:

Abort script
Continue to the next iteration
Continue to the next step

 

"Continue to the next step" is for your case.

This option is available in General Settings > Interactive Options (for interactive mode replay) and in Other tabs in Runtime Settings (for load mode replay).

0 Likes
Highlighted
Trusted Contributor.. Trusted Contributor..
Trusted Contributor..

Re: TruClient: exiting a function() to continue script

Hi @Alex Zhou

 thanks fo your advice,  but my problem is, what could the next step be, so that I leave the function I am in? 
In my example  If the  calculator is unavailable I don't need to enter numbers.  I want to exit the function() and return  into the action() to start the next function() e.g. check accountings.
 
In some cases I worked with if object exist, but it slows the script extremly down, when an app/service on the page is unavailable.
 
I do work  with TC  from the first days on, but I never found a working solution. The effect of "continue to next step" are the following:
When I catch the error with evaluate js-step
fail;
the script continues with trying to enter numbers in the unavailable calculator and obvisously failes.
When I catch the error with an exit-step with exit(action) the script sktips into the next iteration or runs into the end-block defined in the Run Logic Tree no matter where I add the calculator-action in the tree.
 
Isn't it possible to exit/return only the function() with some javascript code?
(sorry for the 3. update)
 
Thanks Pascal
0 Likes
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: TruClient: exiting a function() to continue script

Hi @PascalCalovini,

When I need to skip some sections/steps in a function (after error condition), I put those sections/steps in an IF or multiple IFs and set a global JS variable to enable/disable the flow. At the end of the function I make sure that the JS variable returns to a predefined state.

Can you apply this to your problem?

 

Signature:
Reward community members who take time to respond and help.
0 Likes
Highlighted
Trusted Contributor.. Trusted Contributor..
Trusted Contributor..

Re: TruClient: exiting a function() to continue script

Hi @JHF Remmelzwaal,

yeah, I do this a lot to. I catch different errors with some handlers and, call for example http500_handler()-function, set a variable global.http_error = true; but after the handler-function the script returns into the underlying function in the callstack. Depending on the complexity of the app I do use if-clauses (e.g WOP_Fehler == "false") but at level 6 or more it gets really confusing to work in the tree. This way I do have to add a new level each time I have to press a submit-button, instead of "exit this workflow".

Thanx for your ideas

Pascal

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.