如何清除 puppeteer 中的项目值 [英] How to clear an item value in puppeteer
本文介绍了如何清除 puppeteer 中的项目值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含多个项目的 iFrame,我想更新记录.
I have an iFrame with several items and i want to update a record.
const frame = await page.frames()[1];
const P1_CUSTOM_NAME = await frame.$('#P1_CUSTOM_NAME');
await P1_CUSTOM_NAME.type('MyFavoritCustomer', {delay: 20});
这不会覆盖 P1_CUSTOM_NAME
字段.不幸的是,它附加了值 'MyFavoritCustomer'
.
This will not overwrite the field P1_CUSTOM_NAME
. Unfortunately it appends the value 'MyFavoritCustomer'
.
对于如何清除项目值有什么建议吗?
Any suggestions how i can clear an item value?
推荐答案
尝试三次单击以聚焦并全选.
Try a triple click to focus and select all.
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});
这篇关于如何清除 puppeteer 中的项目值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文