-1

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 Answers2

0

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.

Md. Abu Taher
  • 17,395
  • 5
  • 49
  • 73
  • it only put value in first input field . while others remain empty, with for loop it works but values does not save with form. – Saeed Ullah May 27 '19 at 05:21
  • You probably trying to fill up a angular/react/vue form. Check this answer: https://stackoverflow.com/a/56299180/6161265 – Md. Abu Taher May 27 '19 at 05:47
-1

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

    });