how to pass one script variable values to another script in loadrunner

时光总嘲笑我的痴心妄想 提交于 2020-01-07 07:36:10

问题


I am new to load runner and i am preparing script for REST ,here i will get one token in response where i need to use same token value in another script to validate the customer details ,i am using web_reg_save_param t save those value i.e token value in some variable.please help how can i pass that particular value into another script which is dependent.

i have tried below script

if (atoi(lr_eval_string("{SecurityToken}")) > 0)
    {
        lr_end_transaction("01_Cards",LR_PASS);
        lr_output_message(lr_eval_string("Value of Security Token is : {SecurityToken}"));
    }
    else
    {
        lr_end_transaction("01_Cards",LR_FAIL);
        lr_output_message(lr_eval_string("Value of Security Token is : {SecurityToken}"));
    }

回答1:


Your management owes you training and a mentor. You may find this statement infuriating, but it is your management who is setting you up for issues. This is from someone with two decades of experience in this field and who has over a thousand answered questions per year online on the topic of performance testing with and without LoadRunner involved. You can also find a podcast which is directly related to this discipline at http://www.perfbytes.com

Virtual Table Server is the mechanism to do this in LoadRunner. If you do not want to use VTS then you can use other service brokers to handle this. Solutions have been built around MYSQL, RabbitMQ, ORACLE and SQL Server Queue Tables, etc... The architecture of this solution is Virtual user A writes to a queue. Virtual user B, which you are trying to pass the data to, "pops" the next value from the queue. The service oriented architecture of the queue handles the appropriate managing of lock for push onto the queue and pop from the queue for multiple users.

What you cannot do successfully is write to a common file or to a parameter file for another user. This will not work for a half a dozen different reasons related to locking on multiple user access for read/write and delete as well as when and how the parameter files are loaded and addressed by virtual users.




回答2:


Straight away you can't pass one script data in another script, below are alternatives to reach your goal,

  1. Use VTS to share data among scripts.

  2. Merge two scripts into one script.

  3. If possible prior to the load tests, create test data and seed them in script.



来源:https://stackoverflow.com/questions/37607031/how-to-pass-one-script-variable-values-to-another-script-in-loadrunner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!