【问题标题】:Getting an error in output when passing dynamic variable in ElFileBody in Gatling 3.0.3在 Gatling 3.0.3 中的 ElFileBody 中传递动态变量时输出错误
【发布时间】:2019-04-16 03:38:13
【问题描述】:

我使用的是 Gatling 3.0.3,Java home 设置为 Jdk9。使用“ElFileBody”运行脚本时出现错误,并且在 ElFileBody .txt 文件中传递了一个动态变量 Session_ID。下面是我的代码

.exec(http("TEAMXPRESS_INIT")
   .post("/WEBXPAPIT/api/Common/wxRequestHandlerJSON")     
   .headers(headers_7)
.body(ElFileBody("bodies/resources/TeamXPLoginUnSchShift_0021_request.txt")).sJson                                                      

  .check( jsonPath( "$" ).saveAs( "TEAMXP_INIT_RESPONSE_DATA" ) )
  .check(status.in(200))
  .check(jsonPath("$.pcResult").is("OK")))

body/resources/TeamXPLoginUnSchShift_0021_request.txt 文件是

{"pcwxSessionID":"${Session_ID)","pcServiceName":"TeamXpressInit","pcContextString":"{\"ttContext\":[{\"contextName\":\"pcToken\",\"contextValue\":null,\"contextGroup\":\"PARAM\",\"contextOperator\":\"\",\"contextType\":\"\"},{\"contextName\":\"pcPlatform\",\"contextValue\":null,\"contextGroup\":\"PARAM\",\"contextOperator\":\"\",\"contextType\":\"\"}]}","piClientVersion":"20190414001","pcIODataSetString":""}

我得到的错误是

Caused by: java.util.concurrent.CompletionException: io.gatling.core.session.el.ElParserException: Failed to parse {"pcwxSessionID":"${Session_ID)","pcServiceName":"TeamXpressInit","pcContextString":"{\"ttContext\":[{\"contextName\":\"pcToken\",\"contextValue\":null,\"contextGroup\":\"PARAM\",\"contextOperator\":\"\",\"contextType\":\"\"},{\"contextName\":\"pcPlatform\",\"contextValue\":null,\"contextGroup\":\"PARAM\",\"contextOperator\":\"\",\"contextType\":\"\"}]}","piClientVersion":"20190414001","pcIODataSetString":""} with error ''}' expected but ')' found'
    at com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache.lambda$new$0(BoundedLocalCache.java:3373)
    at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2039)
    at java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1922)
    at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2037)
    at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2020)
    at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:112)
    at com.github.benmanes.caffeine.cache.LocalLoadingCache.get(LocalLoadingCache.java:67)
    at io.gatling.core.body.ElFileBodies.asBytesSeq(ElFileBodies.scala:71)
    at io.gatling.core.body.ElFileBody$.apply(Body.scala:34)
    at teamXPLogin.TeamXPLoginUnSchShift.<init>(TeamXPLoginUnSchShift.scala:86)

我在这里做错了什么。如果我使用 StringBody 方法手动传递发布请求正文,那么它可以正常工作。请帮忙。

【问题讨论】:

    标签: gatling


    【解决方案1】:

    我发现自己犯了一个愚蠢的错误。我没有像这样传递动态变量 ${Session_ID},而是传递了 ${Session_ID)。

    【讨论】:

      猜你喜欢
      • 2022-09-28
      • 1970-01-01
      • 2019-09-16
      • 1970-01-01
      • 2016-12-17
      • 1970-01-01
      • 2016-10-14
      • 2013-11-09
      • 2021-03-18
      相关资源
      最近更新 更多