mirror of
https://github.com/MontFerret/ferret.git
synced 2025-01-06 03:03:57 +02:00
Added example of handling lazy loading lists
This commit is contained in:
parent
2f399c669e
commit
0c4a18cb76
5
e2e/tests/examples/lazy-loading.yaml
Normal file
5
e2e/tests/examples/lazy-loading.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
query:
|
||||
ref: ../../../examples/lazy-loading.fql
|
||||
assert:
|
||||
text: RETURN T::LEN(@lab.data.query.result, 50)
|
29
examples/lazy-loading.fql
Normal file
29
examples/lazy-loading.fql
Normal file
@ -0,0 +1,29 @@
|
||||
LET doc = DOCUMENT('https://soundcloud.com/charts/top', { driver: "cdp" })
|
||||
|
||||
LET endSelector = ''
|
||||
LET listSelector = '.chartTracks ul'
|
||||
|
||||
WAIT_ELEMENT(doc, listSelector)
|
||||
|
||||
LET list = ELEMENT(doc, listSelector)
|
||||
LET initialCount = ELEMENTS_COUNT(list, 'li')
|
||||
LET lastItem = 50
|
||||
|
||||
LET preload = (
|
||||
FOR i DO WHILE !ELEMENT_EXISTS(doc, '.chartTracksEnd')
|
||||
LET initial = i > 0 ? SCROLL_BOTTOM(doc) && WAIT(500) && SCROLL_TOP(doc) && false : true
|
||||
|
||||
RETURN NONE
|
||||
)
|
||||
|
||||
WAIT_ELEMENT(list, FMT('li:nth-child({})', lastItem))
|
||||
|
||||
FOR track, i IN ELEMENTS(list, 'li')
|
||||
RETURN {
|
||||
num: i + 1,
|
||||
artist: TRIM(INNER_TEXT(track, '.chartTrack__details .chartTrack__username')),
|
||||
track: TRIM(INNER_TEXT(track, '.chartTrack__details .chartTrack__title'))
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user