Selecting dropdown in WebDriverJs

后端 未结 15 906
星月不相逢
星月不相逢 2020-12-29 07:48

I have a dropdown box that I would like to select a value using WebDriverJS. I\'ve looked at the user guide below and could not find out how to do it

15条回答
  •  有刺的猬
    2020-12-29 08:06

    This will work for me (coffeescript)

    selectList.findElements(By.tagName("option")) =
    .then (options) ->
        len = options.length         #getting number of options in the select
        driver.wait =>               #verify all promises finished
            for option in options
                option.getText()
                .then (text) =>
                    console.log(len)
                    len -= 1
                    console.log(text)
                    if len is 0
                        true
        , 10000 
    

提交回复
热议问题