You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

参数化用户名密码后LoadRunner回放出现HTTP 500错误求助

问题排查:Advantage购物网站LoadRunner参数化后脚本报错500

我在对Advantage在线购物网站进行录制测试,已完成登录、添加商品至购物车及结账流程的录制,但将用户名和密码替换为参数后,脚本无法正常运行。

参数化后的代码片段

web_set_sockets_option("SSL_VERSION", "AUTO");
    
web_set_user(lr_eval_string("{Usuario}"), 
             lr_eval_string("{Password}"),
             "www.advantageonlineshopping.com:443");

web_custom_request("AccountLoginRequest_3", 
    "URL=", 
    "Method=POST", 
    "Resource=0", 
    "RecContentType=text/xml", 
    "Referer=https://www.advantageonlineshopping.com/", 
    "Snapshot=t75.inf", 
    "Mode=HTML", 
    "EncType=text/xml; charset=UTF-8", 
    "Body=<?xml version=\"1.0\" encoding=\"UTF-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><AccountLoginRequest xmlns=\"com.advantage.online.store.accountservice\"><email></email><loginPassword>{Password}</loginPassword><loginUser>{Usuario}</loginUser></AccountLoginRequest></soap:Body></soap:Envelope>", 
    LAST);

web_set_sockets_option("INITIAL_AUTH", "BASIC");

web_url("907992560_11", 
    "URL=https://www.advantageonlineshopping.com/order/api/v1/carts/907992560", 
    "Resource=0", 
    "RecContentType=application/json", 
    "Referer=https://www.advantageonlineshopping.com/", 
    "Snapshot=t76.inf", 
    "Mode=HTML", 
    LAST);

回放错误信息

Login.c(128): Error -26611: HTTP Status-Code=500 (Internal Server Error) for "https://www.advantageonlineshopping.com/order/api/v1/carts/907992560"    [MsgId: MERR-26611]

双击错误提示会定位到最后一个web_url请求。未使用参数时脚本可正常回放,注释该报错代码后,后续动作又出现其他错误。


排查及解决方案

  • 移除web_set_user中的lr_eval_string:LoadRunner会自动解析参数,嵌套lr_eval_string()会导致参数解析异常,修改后代码应为:
    web_set_user("{Usuario}", 
                 "{Password}",
                 "www.advantageonlineshopping.com:443");
    
  • 关联购物车ID:web_url中的购物车ID 907992560是录制时的会话专属值,参数化登录后新会话的购物车ID不同,需在登录或加购请求的响应中提取该ID,替换硬编码值。可通过web_reg_save_param函数实现关联,比如在登录请求前添加关联规则,捕获响应中的购物车ID。
  • 调整认证设置顺序:将web_set_sockets_option("INITIAL_AUTH", "BASIC")移至web_set_user之前,确保认证配置先于用户认证生效:
    web_set_sockets_option("SSL_VERSION", "AUTO");
    web_set_sockets_option("INITIAL_AUTH", "BASIC");
      
    web_set_user("{Usuario}", 
                 "{Password}",
                 "www.advantageonlineshopping.com:443");
    
  • 验证参数实际值:开启LoadRunner的Extended Log(勾选Data returned和Full request logging),回放时查看请求Body和认证信息,确认{Usuario}和{Password}是否正确替换,无空值或转义错误。

内容的提问来源于stack exchange,提问作者Kuroi Walker

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 05:13:10