From b0344871c76aa5b6258b728f2d8126c8acc0efbc Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Mon, 9 Jun 2025 16:43:18 +0800 Subject: [PATCH 1/2] Expand form demo to use a few keyboard actions --- public/form/get.html | 5 +++-- puppeteer/form.js | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/public/form/get.html b/public/form/get.html index c51dcb7..8c2f93a 100644 --- a/public/form/get.html +++ b/public/form/get.html @@ -3,8 +3,9 @@
- + + +
- diff --git a/puppeteer/form.js b/puppeteer/form.js index a6f1962..659cd3c 100644 --- a/puppeteer/form.js +++ b/puppeteer/form.js @@ -30,7 +30,11 @@ const page = await context.newPage(); await testForm(page, '/form/get.html', { method: 'GET', body: '', - query: 'h1=v1&h3=v3&favorite+drink=tea', + query: 'h1=v1&h3=v3hello&favorite+drink=tea&ta=over+9000%21', +}, async() => { + await page.type('#input', 'hello'); + await page.type('#ta', 'over 9000!'); + await page.click('#submit'); }); await testForm(page, '/form/post.html', { From 413b88a7cc7bf30b50e4a13a4ddd6ccb653d563d Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Wed, 11 Jun 2025 19:36:23 +0800 Subject: [PATCH 2/2] Form submit via "Enter" keypress within text input field --- puppeteer/form.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/puppeteer/form.js b/puppeteer/form.js index 659cd3c..953d1ff 100644 --- a/puppeteer/form.js +++ b/puppeteer/form.js @@ -30,11 +30,12 @@ const page = await context.newPage(); await testForm(page, '/form/get.html', { method: 'GET', body: '', - query: 'h1=v1&h3=v3hello&favorite+drink=tea&ta=over+9000%21', + query: 'h1=v1&h3=v3hello&favorite+drink=tea&ta=OVER+9000%21', }, async() => { await page.type('#input', 'hello'); - await page.type('#ta', 'over 9000!'); - await page.click('#submit'); + await page.type('#ta', 'OVER 9000!'); + await page.focus('#input'); + await page.keyboard.press('Enter'); }); await testForm(page, '/form/post.html', {