Commit e6f250d
committed
behaviors: add loop control selector
Right now, our loop config in behaviours is purely based on the loop
limit. We can be smarter than that, though - sometimes we can know
when it's safe to *stop* clicking the same element over and over by
running another selector.
A good example of this is page pagination. Most sites with
JavaScript-based pagination will also disable the "next" button once
the browser has reached the last page of results. Using that, we can
configure a behaviour that looks something like this:
```yaml
- url_regex: '^.*$'
behavior_js_template: umbraBehavior.js.j2
request_idle_timeout_sec: 10
default_parameters:
interval: 10
actions:
- selector: .next
repeatSameElement: true
repeatUntilSelector: .next[disabled]
# the repeatUntil selector makes long loops safe
# since we'll break out of the loop once we hit the
# disabled button!
limit: 1000
```1 parent 47f5c06 commit e6f250d
1 file changed
+10
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
96 | | - | |
97 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
98 | 106 | | |
99 | 107 | | |
100 | 108 | | |
| |||
0 commit comments