首页 > 解决方案 > 空手道 UI:如何单击具有相同类名的特定复选框

问题描述

场景:一堆复选框将所有相同的类名排成一行。在这种特定情况下,对复选框名称使用“rightOf”不起作用。

在此处输入图像描述

上图显示 div 有 id,但无法点击。可点击部分由具有多个其他类似复选框的共享类名称标识。

问题:如何单击共享相同类名的第三个或第四个复选框?

标签: karate

解决方案


First, you can do a locateAll() and then navigate:

* locateAll('.myclassname')[2].click()

For more advanced filtering, read the docs on using a "filter condition" with locateAll(): https://github.com/intuit/karate/tree/master/karate-core#locateall-with-filter

For completeness, if you can get hold of the parent of the bunch: https://github.com/intuit/karate/tree/master/karate-core#tree-walking

* parent.children[2].click()

推荐阅读