javascript - 如何将计数传递给动态 json 对象
问题描述
我对 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 次
解决方案
可能最好使用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
推荐阅读
- angular - 将 @ngrx/router-store 操作与 ngrx 8 createReducer() 和 on() 函数一起使用
- roslyn - 在 Visual Studio 2019 Preview 4 中使用通用 .editorconfig 文件(在 csproj 中导入)的问题
- mysql - 此 SQLMAP 有效负载中的此 SQL 查询有什么作用?
- iis - 使用 NTLM 时的 Windows IIS 会话超时设置 (Windows 10)
- python - 检查文件的一行中的变量是否完全相同-Tkinter
- gis - 如何在 QGIS Server 中显示图层组
- java - 如何使用 JAVA 在 XML 中设置属性值
- python - 如何将函数输出添加到文本文件中?
- c - 为什么我的程序不能正确地将十进制转换为二进制打印?
- jquery - 出现错误:“无法读取未定义的属性 'toLowerCase'”在 filter() 函数中使用 Jquery find()