1

I am stuck with a case where the need is to click on an icon after asserting inputs from the user. In case there were some unique identifiers, the thing was pretty simple like the use of: rightOf('{}UniqueIdentifier').find('i').click() served the purpose. Also working fine with: scroll('{}UniqueIdentifier').parent.children[4].click()

But in case the table contains repeated values nothing could be found unique to search for and click. For which the thought was to match entire row text where the last element is that icon which needs to be clicked OR any other method which suits this?

Table looks like this:-
enter image description here

Need to click on triple dot icon for- A2,P2,2,resolved. How can this be achieved using wildcard locators? I tried creating a list of elements and match it with user input list but failed doing so.

Any help would be appreciated. Thanks!

Uncle Sam
  • 255
  • 3
  • 11

1 Answers1

0

First you should get comfortable with locateAll(). It will return an array of Element objects. And after that there are many possible ways of looping over and finding what you want.

Also note that there is a "locateAll() with filter": https://github.com/intuit/karate/tree/master/karate-core#locateall-with-filter

Since you haven't provided any HTML I will have to guess. And note that x below is an Element and you can even call locate() on it.

* def filter = function(x){ x.text.contains('Unique Identifier') }
* def list = locateAll('.grand-parent-class', filter)
* list[0].parent.children[4].click()
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248