mahesh nani mahesh nani - 1 year ago 144
Node.js Question

Selenium get all options from drop down in node.js

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

below is my code:

var dropdown = driver.findElement({xpath: '//*[@name="dropdownname"]'});

from above

var options = dropdown.findElements({tagName: 'option'});

how can i get all options and do foreach in node.js or print options values using node.js.

Thanks in advance.

Answer Source
driver.findElement({xpath: '//*[@name="dropdownnamewithoptions"]'}).then(function(webElement) {
                        if(optionArray.length > 1){
                                  optionArray[0].getAttribute('value').then(function(optionValue) {
                 }, function(err) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download