The following code doesn't work due to a ReferenceError when trying to access uid
. I understand that the eval
code is running inside the browser's context and thus doesn't have access to this variable, but I don't know how to pass the variable's value regardless:
var uid = 'foo@example.com';
await page.$eval('#uid', el => el.value = uid);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…