Selenium get all options from drop down in node.js

后端 未结 1 525
误落风尘
误落风尘 2020-12-21 23:05

How can I get all options from drop down using selenium with node.js

below is my code:

var dropdown = driver.findElement({xpath: \'//*[@name=\"dropdo         


        
相关标签:
1条回答
  • 2020-12-21 23:21
    driver.findElement({xpath: '//*[@name="dropdownnamewithoptions"]'}).then(function(webElement) {
                        webElement.findElements(By.tagName('option')).then(function(optionArray){
                            if(optionArray.length > 1){
                                      optionArray[0].getAttribute('value').then(function(optionValue) {
                     });
                            }
                        });
                     }, function(err) {
                    });
    
    0 讨论(0)
提交回复
热议问题