pw-repl 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/elements.js +7 -9
- package/lib/help.js +3 -3
- package/package.json +1 -1
package/lib/elements.js
CHANGED
|
@@ -242,12 +242,10 @@ async function smoothWheel(dx, dy) {
|
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
// While the tab records, text is typed at a pace a viewer can follow, steady rather than human-like
|
|
246
|
-
//
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
if (!recordingOf(state.page) || !text.length) return 0;
|
|
250
|
-
return Math.round(Math.min(60, 8000 / text.length));
|
|
245
|
+
// While the tab records, text is typed at a pace a viewer can follow, steady rather than human-like.
|
|
246
|
+
// Otherwise at once, as before.
|
|
247
|
+
function typingPace() {
|
|
248
|
+
return recordingOf(state.page) ? 60 : 0;
|
|
251
249
|
}
|
|
252
250
|
|
|
253
251
|
// check, uncheck and upload's button click it at its centre, where aimFor put the cursor.
|
|
@@ -399,7 +397,7 @@ const commands = {
|
|
|
399
397
|
const paced = /^\s*--delay(?:=|\s+)(\S*)(?:\s+|$)/.exec(line || '');
|
|
400
398
|
if (paced && !/^\d+$/.test(paced[1])) throw new Error('Usage: type --delay=<ms> [<selector>] <text>, the pause between keys, e.g. type --delay=80 #search garden hose');
|
|
401
399
|
const { args, submit } = submitFlag(paced ? line.slice(paced[0].length) : line);
|
|
402
|
-
const delay =
|
|
400
|
+
const delay = () => (paced ? Number(paced[1]) : typingPace());
|
|
403
401
|
// One word, or one quoted, is typed into the focused element, as playwright-cli's type does.
|
|
404
402
|
const sole = splitSelector(args);
|
|
405
403
|
if (sole && sole.rest === undefined) {
|
|
@@ -414,7 +412,7 @@ const commands = {
|
|
|
414
412
|
const usage = 'type <selector> <text> types into an element, e.g. type #search garden hose';
|
|
415
413
|
if (!focused) throw new Error(`Nothing on the page has focus: ${usage}`);
|
|
416
414
|
if (!focused.editable) throw new Error(`The focused element, ${focused.name}, takes no text: ${usage}`);
|
|
417
|
-
await state.page.keyboard.type(sole.word, { delay: delay(
|
|
415
|
+
await state.page.keyboard.type(sole.word, { delay: delay() });
|
|
418
416
|
if (submit) await state.page.keyboard.press('Enter');
|
|
419
417
|
out.log(`Typed into the focused ${focused.name}${submit ? ', and submitted' : ''}`);
|
|
420
418
|
return;
|
|
@@ -435,7 +433,7 @@ const commands = {
|
|
|
435
433
|
getSelection().addRange(range);
|
|
436
434
|
}
|
|
437
435
|
}, null, { timeout }));
|
|
438
|
-
await state.page.keyboard.type(value, { delay: delay(
|
|
436
|
+
await state.page.keyboard.type(value, { delay: delay() });
|
|
439
437
|
if (submit) await state.page.keyboard.press('Enter');
|
|
440
438
|
out.log(`Typed into${submit ? ' and submitted' : ''}: ${shown}`);
|
|
441
439
|
},
|
package/lib/help.js
CHANGED
|
@@ -199,9 +199,9 @@ Examples: fill #name Ada Lovelace, fill "text=Your name" Ada, fill e7 Ada`,
|
|
|
199
199
|
--submit at the end presses Enter afterwards.
|
|
200
200
|
|
|
201
201
|
Keys are sent all at once. While the tab is recording (help record), they are 60ms apart, so the video
|
|
202
|
-
shows the text being typed
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
shows the text being typed. type --delay=<ms> <selector> <text> sets the gap between keys yourself. The
|
|
203
|
+
whole text takes its length times the gap, and send waits 20s by default: about 300 characters at 60ms
|
|
204
|
+
need a longer send -t, or a shorter --delay. It is a gap between keys, not a wait before starting like
|
|
205
205
|
screenshot's --delay. A page that reacts to each key, such as search as you type, may react to each one.`,
|
|
206
206
|
},
|
|
207
207
|
press: { usage: 'press <key> | press <selector> <key>', summary: 'press a key (Enter, Escape, Control+A; any case), maybe on an element' },
|