Automation 使用karate.call传递多个参数

Automation 使用karate.call传递多个参数,automation,cucumber,karate,web-api-testing,Automation,Cucumber,Karate,Web Api Testing,我试图在第二个功能文件中调用API,从第一个功能文件传递参数。比如从第一个API响应返回的令牌和当前页值。它们必须作为第二个API的参数传递 * def activeDetails = """ function(times){ for(i=0;i<=times;i++){ karate.log('Run test round: '+(i+1)); karate.call('getActiveRouteDeta

我试图在第二个功能文件中调用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

当您处于JavaScript块中时,会有细微的差别。请阅读:

进行以下更改:

var result = karate.call('examples/getDetails.feature', { token: token, currentPage, i });
请不要使用像
当前页面
这样的变量名,如果需要帮助,请向JavaScript程序员朋友寻求帮助


还要注意的是,最佳做法是尽可能避免JS代码和循环:

@PeterSmith谢谢您,先生。我会在查看您提供的链接后更新代码。我正面临前面提到的另一个问题。你能提供你的电话号码吗input@anonymous请将此答案标记为“已接受”并提出新问题,并保持其简单明了
var result = karate.call('examples/getDetails.feature', { token: token, currentPage, i });