Selecting dropdown in WebDriverJs

后端 未结 15 1191
星月不相逢
星月不相逢 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 07:58

    I was using the following with ES6:

     let select = driver.findElement(By.css("select"));
     let options = select.findElements(By.css("option"));
     options.then(values => {
         return Promise.all(values.map(el => el.getText())).then(optTexts => {
             return values[optTexts.indexOf('Some option text')].click();
         });
     });
    

提交回复
热议问题