Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

puppeteer clear input

// You can use page.evaluate to manipulate DOM as you see fit:
await page.evaluate( () => document.getElementById("inputID").value = "");

// Here we press Backspace as many times as there are characters in that field:
const inputValue = await page.$eval('#inputID', el => el.value);
for (let i = 0; i < inputValue.length; i++) {
  await page.keyboard.press('Backspace');
}

/*
Another interesting solution is to click the target field 3 times.
so that the browser would select all the text in it and then you could just type what you want:
*/
const input = await page.$('#inputID');
await input.click({ clickCount: 3 });
await input.type("Blah");
Comment

PREVIOUS NEXT
Code Example
Javascript :: scrolltop top to bottom body get count 
Javascript :: check object has value 
Javascript :: Hide elements until Alpine Js loads 
Javascript :: conditinally object property js 
Javascript :: js get array item by property 
Javascript :: javascript make beep sound 
Javascript :: get keys of dictionary js 
Javascript :: login discord token 
Javascript :: javascript truncate string 
Javascript :: laravel 8 include javascript in blade 
Javascript :: how to find text in jquery with find function 
Javascript :: js conditional object property 
Javascript :: append to array check if exists javascript 
Javascript :: discord js user has role 
Javascript :: regex cnpj javascript 
Javascript :: get distance of element from top of page javascript 
Javascript :: moment js add day 
Javascript :: npm youtube-react 
Javascript :: js parse url decode 
Javascript :: fibonacci sequence in javascript 
Javascript :: reaact native expo jsx 
Javascript :: javascript with html 
Javascript :: get current scroll height javascript 
Javascript :: javascript loop thrown object 
Javascript :: unpack array into variables javascript 
Javascript :: javascript copy and paste event 
Javascript :: js nwe date today 
Javascript :: delete parent element javascript 
Javascript :: js after now 
Javascript :: exiting jshell 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =