Skip to content

Commit a94c4e7

Browse files
committed
refactor(tests): Make sendKeyAndWait faster if PAUSE_TIME === 0
Making a single webdriverio call is much faster when sending repeating keypresses; do that if we don't need to pause.
1 parent 48d2da2 commit a94c4e7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/webdriverio/test/test_setup.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,15 @@ export async function sendKeyAndWait(
552552
keys: string | string[],
553553
times = 1,
554554
) {
555-
for (let i = 0; i < times; i++) {
555+
if (PAUSE_TIME === 0) {
556+
// Send all keys in one call if no pauses needed.
557+
keys = Array(times).fill(keys).flat();
556558
await browser.keys(keys);
557-
await browser.pause(PAUSE_TIME);
559+
} else {
560+
for (let i = 0; i < times; i++) {
561+
await browser.keys(keys);
562+
await browser.pause(PAUSE_TIME);
563+
}
558564
}
559565
}
560566

0 commit comments

Comments
 (0)