Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear an item value in puppeteer

Tags:

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?

like image 956
Stefan Roess Avatar asked Oct 24 '17 10:10

Stefan Roess


People also ask

How do you clear a puppeteer field?

However, you CAN clear it as you would if you were using Google Chrome, a triple click and a backspace.

How do you find the value of an element in a puppeteer?

How do you find the value of an element in a puppeteer? page. $eval() function is used to get the value for an element in puppeteer. $eval will stage two-parameter as an argument first parameter will be the selector and the second parameter will be element= element.

How do you value a playwright?

await page. locator('input#my-input'). inputValue();


1 Answers

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});
like image 70
Matt Avatar answered Sep 30 '22 13:09

Matt