使用karate.call传递多个参数

问题描述 投票:1回答:1

我正在尝试在第二个功能文件中调用API,并从第一个功能文件传递参数。请说出第一个API响应返回的令牌和当前页面值。这些值必须作为第二个API的参数传递]

   * def activeDetails =
    """
      function(times){
        for(i=0;i<=times;i++){
          karate.log('Run test round: '+(i+1));
          karate.call('getActiveRouteDetails.feature', { token: token, currentPage: i });
        }
        java.lang.Thread.sleep(1*1000);
      }
    """
* call activeDetails totalPages

在我的第二个功能中,我能够打印传递的值,但是无法传递params。您能帮我吗

And print currentPage
And print token
And param pageNumber  = '#currentPage'
And param token = token
automation cucumber karate web-api-testing
1个回答
0
投票

当您位于JavaScript块中时,会有细微的差别。请阅读:https://github.com/intuit/karate#karate-expressions

进行此更改:

var result = karate.call('examples/getDetails.feature', { token: token, currentPage, i });

并且请不要使用像current page这样的变量名,如果需要帮助,请寻求JavaScript程序员的帮助。

还请注意,最佳实践是尽可能避免JS代码和循环:https://github.com/intuit/karate#loops

© www.soinside.com 2019 - 2024. All rights reserved.