Highlighted
Absent Member.
Absent Member.
517 views

How To Skip Remaining part of script if transaction fails

I want to know how can I skip the remaining part of script if my first transaction is failing.

e.g. lr_start_transaction(Login)
login script
lr_end_transaction(Login,LR_AUTO)
further transactions

Now if my login transaction fails. I do not want the remaining to continue. How do I do that. I have checked on "Continue on Error" settings. Hence the script continues. So how do I stop that.


0 Likes
4 Replies
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

If you uncheck Continue on Error then it stops if any step fails. 🙂 As simple as that!!

-Madhu
0 Likes
Highlighted
Absent Member.
Absent Member.

No, I want the continue on error. Can anything be done to cointinue if only the previous transaction passes.
0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

I didn't understand your requirement. But, two things i can explain which you can control the navigation programatically.

- lr_get_transaction_status - Gives you the status of transaction ie., fail/pass
- lr_continue_on_error - Same as the one in Runtime Settings, but you can turn on/off in the script whenever required.

-Madhu
0 Likes
Highlighted
Absent Member.
Absent Member.

You can use the following code, and customize according to your requirements.


web_reg_find("Text=Login to your application", "SaveCount=Text_Count",LAST);


Your webpage details



if (atoi(lr_eval_string("{Text_Count}")) > 0){
lr_output_message("Login page successful");
lr_end_transaction("Login ", LR_PASS);
}
else{
lr_error_message("Login page failed");
lr_error_message("Running user %s",lr_eval_string ( "{UserID}" ) );
lr_end_transaction("Login ", LR_FAIL);
lr_think_time( sb_random_wait(atoi(lr_eval_string("{ThinkMax}")), atoi(lr_eval_string("{ThinkMin}"))));
lr_exit(LR_EXIT_ITERATION_AND_CONTINUE, LR_FAIL);
return(0);


In lr_exit function, you can use different conditions available in the help, according to your requirement.
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.