【问题标题】:How to pass in a count to dynamic json object [duplicate]如何将计数传递给动态json对象[重复]
【发布时间】:2020-06-30 01:17:30
【问题描述】:

我对 javascript 很陌生。我试图找到一种从 0-5 计数的方法,并将这些数字成对放置,然后调用一个函数来单击与其索引值相关的框。这是我目前所拥有的:

* table deviceValsTable
     | boxLocator    | indexList |
     | brandCheckbox |   [0,1]   |
     | brandCheckbox |   [0,2]   |
     | brandCheckbox |   [0,3]   |
     | brandCheckbox |   [0,4]   |
     | brandCheckbox |   [0,5]   |
     | brandCheckbox |   [1,2]   |
     | brandCheckbox |   [1,3]   |
     | brandCheckbox |   [ect..]   |
 * def indexList = karate.get('indexList')
    * def locator = karate.get('boxLocator')
    * def boxes = locateAll(locator)
    * def clickBox = function(index){ boxes.get(index).click()}
    * karate.map(indexList, clickBox) 

我需要这样做 16 次

【问题讨论】:

    标签: javascript karate


    【解决方案1】:

    最好使用Scenario Outline:https://github.com/intuit/karate#data-driven-tests

    Scenario Outline:
    * print indexList
    
    Examples:
    | indexList! |
    | [0, 1]     |
    | [2, 0]     |
    

    注意Scenario Outline-s 可以采用动态数据源:https://github.com/intuit/karate#dynamic-scenario-outline

    另见循环:https://github.com/intuit/karate#loops

    【讨论】:

    • 嘿彼得,非常感谢您的回复。我不认为我正确地问了我的问题。就像我说的我对这种语言很陌生。我试图做这样的事情; for (i=1; i
    • 感谢您的宝贵时间,彼得,我会继续阅读文档。
    猜你喜欢
    • 2021-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多