How to save input values on server using puppeteer?

199 Views Asked by At

How to save input fields value on server ? i want to save form value after i submit the values disappears when i reopen the form .

 await page.$$eval("input[data-bind='value: SyringeOut']",el=>{
            for(i=0; i<el.length; i++){
                el[i].value=3; 
            }
        });
2

There are 2 best solutions below

2
Md. Abu Taher On

page.$$eval does the following,

  • Runs a querySelectorAll inside the page.
  • Creates an array from the result.
  • Maps over the array for you. So it returns a single element and runs your function through it.

Consider rewriting your example like below,

await page.$$eval("input[data-bind='value: SyringeOut']", element => element.value = 3)

So you should not do a for loop inside the el => {} block. Since it's a single element.

0
Saeed Ullah On

all i have to first double click on input element then type figure/value in it. the final code look like this

await page.$$("input[data-bind='value: SyringeOut']").then(async(ee)=>{
        for(var i=0; i<ee.length; i++){
            await ee[i].click({clickCount:2});
            await ee[i].type('3');
            }

    });