0

I'm having trouble with the pupetter evaluate function. Im declaring a variable outside the function and pass it through. Inside the function it does not work and just makes it undefinied. Any help is apreciated!

let fname = lines[Math.floor(Math.random() * lines.length)].toString()
let lname = lines[Math.floor(Math.random() * lines.length)].toString()

  await page.evaluate((fname, lname) => {
      document.getElementById('first-name-su').value = fname;
      document.getElementById('last-name-su').value = lname;
    }

thats not the full code, just the snipbit of what is not working

Bmoney
  • 11
  • 1
  • Add the `fname` and `lname` vars as additional parameters to `evaluate` so they're passed into the callback. – ggorlen Jun 16 '21 at 02:14
  • Does this answer your question? [How can I pass variable into an evaluate function?](https://stackoverflow.com/questions/46088351/how-can-i-pass-variable-into-an-evaluate-function) – ggorlen Jun 16 '21 at 02:16

0 Answers0