Skip to content

Commit

Permalink
improve readme for #1123
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed May 3, 2020
1 parent dcd0c4a commit 2527a7c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions karate-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,14 @@ Imagine a situation where you want to get only the element where a certain attri

The `filter` function above, will be called for each [`Element`](src/main/java/com/intuit/karate/driver/Element.java) - which means that you can call methods on it such as [`Element.attribute(name)`](#chaining) in this case. Note that the JS function in this case is run by *Karate* not the browser, so you use the Java `String.startsWith()` API.

Since you can call `Element.script()` - *any* kind of filtering will be possible. For example here is the equivalent of the example above. Note the combination of "Karate JavaScript" and ["JS that runs in the browser"](#karate-vs-the-browser):

```cucumber
* def filter = function(x){ return x.script("_.getAttribute('data-label')").startsWith('myQues1_1') }
* def list = locateAll('div[data-label]', filter)
* list[0].click()
```

See also [`scriptAll()` with filter](#scriptall-with-filter).

## `refresh()`
Expand Down

0 comments on commit 2527a7c

Please sign in to comment.