条件不使用另一个功能文件调用 [英] Condition without using another feature file call

查看:19
本文介绍了条件不使用另一个功能文件调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用空手道,我想知道是否可以设置 If 条件而无需调用不同的功能文件(而不是使用 JavaScript)->在条件下使用空手道特征文件代码块:

Using Karate, I would like to know, if it is possible to set If condition without necessity of calling different feature file (and not using JavaScript) -> using block of Karate feature file code in condition:

例如应该可以做这样的事情吗?

e.g. it should be possible to do something like that?

* if (variable==1) {
     * delay(3000)
     * retry().click('{button[3]/span}Text1')
     } 
     {
     * retry().click('{button[2]/span}Text2')
     * delay(3000)
      } 

是否可以在不使用只有几行代码的单独功能文件的情况下以某种方式做到这一点?你有什么建议吗?

Is it possible to do somehow like this without using separate feature file with only few rows of code? Do you have any advice?

推荐答案

是的,使用 eval 关键字 - 你可以做到纯"JS和多行:

Yes, use the eval keyword - and you can do "pure" JS and on multiple lines:

* eval
"""
  if (variable == 1) {
    delay(3000);
    retry().click('{button[3]/span}Text1');
  } else {
   retry().click('{button[2]/span}Text2');
   delay(3000);
  }
"""

顺便说一下,由于你似乎在做很多高级测试,我建议你开始使用 1.0 RC 版本,这样你就不会得到任何惊喜,也可以提供反馈:https://github.com/intuit/karate/wiki/1.0-upgrade-guide

By the way, since you seem to be doing a lot of advanced testing, I suggest you start using the 1.0 RC version so that you don't get any surprises and you can provide feedback also: https://github.com/intuit/karate/wiki/1.0-upgrade-guide

这篇关于条件不使用另一个功能文件调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆