问题
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