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'))
推荐阅读
- php - 期望语句-php 语法| 如果别的
- php - 如何在php中使用今天的日期和出生日期计算年龄
- android-studio - 从启动特定活动开始时 startActivityForResult() 是否不起作用?
- python - 从 Python 中的单纯形中随机均匀采样
- android - 如何按当前登录的用户在顶部对列表进行排序
- apache-kafka - filebeat将输出设置为kafka,遇到“丢弃无效消息”,这是怎么回事
- javascript - 如何在jquery或javascript中获得小数点后的精确两位数
- flutter - 如何将字符串日期转换为日期时间?
- java - 如何使用 RxJava 重复当
- sql - 如何在 SQL 中使用带参数的 select