首页 > 解决方案 > 空手道 - locateAll 过滤器和输入字段

问题描述

根据空手道的说法,使用空手道 - 是否可以根据部分参数找到元素我尝试使用以下方法:

* def filter = function(x){ return x.attribute('placeholder').startsWith('Very') }
* def list = locateAll('input[placeholder]', filter)

但我不知道如何使用它来插入值。我试过这个:

* retry().input(list[0], '12312312311111')

和这个:

* retry().input('list[0]', '12312312311111')

但都没有奏效。

你知道语法有什么问题吗?

谢谢你。

标签: automated-testskarate

解决方案


任何locate返回的都是一个Element对象。所以你可以在上面调用方法。请阅读文档:https ://github.com/intuit/karate/tree/master/karate-core#locate

所以这应该工作:

* list[0].input('12312312311111')
* list[0].retry().input('12312312311111')

推荐阅读