Stefan Roess
Stefan Roess

Reputation: 51

How to clear an item value in puppeteer

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?

Upvotes: 5

Views: 4235

Answers (1)

Matt
Matt

Reputation: 2298

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

Upvotes: 4

Related Questions