Skip to content

Commit 85d08c0

Browse files
committed
Added scroll to all scenarios; Moved it after HTTP status code check
1 parent d81002c commit 85d08c0

File tree

3 files changed

+53
-7
lines changed

3 files changed

+53
-7
lines changed

templates/website/usage_scenario.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ flow:
1717
- type: console
1818
command: sleep '__GMT_VAR_SLEEP__'
1919

20+
- name: Check HTTP Status Code
21+
container: gmt-playwright-nodejs
22+
hidden: true
23+
commands:
24+
- type: playwright
25+
command: if (!page_result.ok()) throw `Page was not accessible. HTTP Return code ${page_result.status()}`
26+
2027
- name: Scroll down and wait for __GMT_VAR_SLEEP__ s
2128
container: gmt-playwright-nodejs
2229
commands:
@@ -39,10 +46,3 @@ flow:
3946
}
4047
- type: console
4148
command: sleep '__GMT_VAR_SLEEP__'
42-
43-
- name: Check HTTP Status Code
44-
container: gmt-playwright-nodejs
45-
hidden: true
46-
commands:
47-
- type: playwright
48-
command: if (!page_result.ok()) throw `Page was not accessible. HTTP Return code ${page_result.status()}`

templates/website/usage_scenario_cached.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,26 @@ flow:
3030
commands:
3131
- type: playwright
3232
command: if (!page_result.ok()) throw `Page was not accessible. HTTP Return code ${page_result.status()}`
33+
34+
- name: Scroll down and wait for __GMT_VAR_SLEEP__ s
35+
container: gmt-playwright-nodejs
36+
commands:
37+
- type: playwright
38+
command: |
39+
let loop_ticks = 0;
40+
const max_loop_ticks = 200;
41+
42+
while (loop_ticks < max_loop_ticks) {
43+
const atBottom = await page.evaluate(() => {
44+
const d = document.documentElement;
45+
return d.scrollTop + window.innerHeight >= d.scrollHeight;
46+
});
47+
if (atBottom) break;
48+
49+
await page.mouse.wheel(0, 200);
50+
await page.waitForTimeout(200);
51+
52+
loop_ticks++;
53+
}
54+
- type: console
55+
command: sleep '__GMT_VAR_SLEEP__'

templates/website/usage_scenario_cached_debug.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,29 @@ flow:
4343
- type: playwright
4444
command: if (!page_result.ok()) throw `Page was not accessible. HTTP Return code ${page_result.status()}`
4545

46+
- name: Scroll down and wait for __GMT_VAR_SLEEP__ s
47+
container: gmt-playwright-nodejs
48+
commands:
49+
- type: playwright
50+
command: |
51+
let loop_ticks = 0;
52+
const max_loop_ticks = 200;
53+
54+
while (loop_ticks < max_loop_ticks) {
55+
const atBottom = await page.evaluate(() => {
56+
const d = document.documentElement;
57+
return d.scrollTop + window.innerHeight >= d.scrollHeight;
58+
});
59+
if (atBottom) break;
60+
61+
await page.mouse.wheel(0, 200);
62+
await page.waitForTimeout(200);
63+
64+
loop_ticks++;
65+
}
66+
- type: console
67+
command: sleep '__GMT_VAR_SLEEP__'
68+
4669

4770
- name: Dump Log (Load and idle)
4871
hidden: true

0 commit comments

Comments
 (0)