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

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -