如何使用节点Puppeteer设置select的值 [英] How to set value of select with node Puppeteer
本文介绍了如何使用节点Puppeteer设置select的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用相当新的GoogleChrome/puppeteer库进行一些自动化,但是我不知道如何在选择字段中设置值.
I am trying to do some automation with the rather new GoogleChrome/puppeteer library, but I cannot figure out how to set a value in a select field.
这是我的(简化的)函数,用于设置文本输入的值:
Here is my (simplified) function to set the value of a text input:
async function setInputVal(sel, text) {
await page.focus(sel)
page.press('Backspace')
page.type(text)
}
await setInputVal('input.searchjob', task.id)
我不知道如何对选择字段执行相同的操作.
I cant figure out how to do the same for a select field.
我试图设置焦点,插入脚本并执行,但是我无法使其工作.
I have tried to set the focus, insert script and execute but I cannot get it working.
推荐答案
您可以使用 查看全文