【问题标题】:Using karate framework and javascript the scenario is looping continuously使用空手道框架和javascript,场景不断循环
【发布时间】:2018-10-05 23:50:48
【问题描述】:

使用空手道框架,我正在调用池化 js 函数,如下所示。即使在实际状态移动完成后,它也会重复该场景。我想知道如何停止循环,一旦实际状态完成就不需要再次调用场景

  """
  function(status) {
    var actualstatus = null
    while (actualstatus != 'Complete') {
      var packageId = {"packageid": packageid}; 
      var result = karate.call('extractProgress.feature',packageId); 
      var greeting = result.response;

      if(greeting.payload.progressStatus == status) 
        { actualstatus = greeting.payload.progressStatus
         return;} 
      actualstatus = greeting.payload.progressStatus
      java.lang.Thread.sleep(100); 
    }
  }
  """ 

场景:一个

* def packageId = packageid
* def result = call read('Progress.feature') {packageid: '#(packageId)'}
* def current = result.response
* def status = 'Complete'
* call waitUntil status

【问题讨论】:

    标签: javascript karate


    【解决方案1】:

    不确定你的 JS,如果可能,请向你附近的人寻求帮助。

    这是我的尝试,因为我无法完全复制您的环境。把事情简单化。如果循环持续时间过长等,您也可以添加逻辑以退出循环。

    """
      function(status, id) {
        while (true) {
          var jsonArg = { packageid: id }; 
          var result = karate.call('extractProgress.feature', jsonArg); 
          var response = result.response;
          if (response.myPath == status) {
            return;
          }
          java.lang.Thread.sleep(100); 
        }
      }
    """ 
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-10
    相关资源
    最近更新 更多