从空手道列表中删除元素?

Remove elements from a list in karate?

在使用 scripAll() 获取样式属性值列表后,我需要消除一些。想知道 python 中是否有类似 remove() 的东西可以用于相同的目的。

示例: * def list_colors = ["rgb(245,60,86)", "rgb(245,60,86)", "rgb(245,00,00)", "rgb(245,00,00)" ]

想要从列表中删除 rgb(245,00,00)。我如何在空手道中做到这一点?

谢谢

我想你错过了 scriptAll() 可以接受第三个“过滤函数”参数,请参考文档:https://github.com/intuit/karate/tree/master/karate-core#scriptall-with-filter

* def list_colors = scriptAll('.my-css', "_.style['display']", x => !x.includes('245,00,00'))

否则请参考JSON转换:https://github.com/intuit/karate#json-transforms

* def filtered = karate.map(list_colors, x => !x.includes('245,00,00'))