How to clear an item value in puppeteer

て烟熏妆下的殇ゞ 提交于 2020-01-14 12:17:45

问题


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});

This will not overwrite the field P1_CUSTOM_NAME. Unfortunately it appends the value 'MyFavoritCustomer'.

Any suggestions how i can clear an item value?


回答1:


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});


来源:https://stackoverflow.com/questions/46907941/how-to-clear-an-item-value-in-puppeteer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!