如何清除 puppeteer 中的项目值

Ste*_*ess 5 puppeteer

我有一个包含多个项目的 iFrame,我想更新一个记录。

const frame = await page.frames()[1];
const P1_CUSTOM_NAME = await frame.$('#P1_CUSTOM_NAME');
await P1_CUSTOM_NAME.type('MyFavoritCustomer', {delay: 20});
Run Code Online (Sandbox Code Playgroud)

这不会覆盖该字段P1_CUSTOM_NAME。不幸的是,它附加了值'MyFavoritCustomer'

任何建议我如何清除项目价值?

Mat*_*att 4

尝试三次单击以聚焦并选择全部。

const frame = await page.frames()[1];
const P1_CUSTOM_NAME = await frame.$('#P1_CUSTOM_NAME');
await P1_CUSTOM_NAME.click({clickCount: 3});
await P1_CUSTOM_NAME.type('MyFavoritCustomer', {delay: 20});
Run Code Online (Sandbox Code Playgroud)