node.js - How to set value of select with node Puppeteer -
i trying automation rather new googlechrome/puppeteer library, cannot figure out how set value in select field.
here (simplified) function set value of 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 same select field.
i have tried set focus, insert script , execute cannot working.
i found solution myself:
async function setselectval(sel, val) { page.evaluate((data) => { return document.queryselector(data.sel).value = data.val }, {sel, val}) } await setselectval('#select_id', 'newvalue')
Comments
Post a Comment