Search code examples
javascriptchromeless

Chromeless - select drop down value


I am using chromeless to change the value of a drop down menu:

var dropDownValue="59"
const screenshot2 = await chromeless
        .evaluate((dropDownValue) => {
            select = document.querySelector('select#category1')
            select.value = dropDownValue
        })

but this is not giving the expected behavior, the drop down menu is set to a "blank" option (which does not even exist in the menu).

What could be going wrong?


Solution

  • Correct syntax is:

    var dropDownValue="59"
    const screenshot2 = await chromeless
            .evaluate((dropDownValue) => {
                select = document.querySelector('select#category1')
                select.value = dropDownValue
            }, dropDownValue)
    

    I don't know why this question was voted down. You might be experts at Chromeless, I'm not.