Getting outliers using selenium and nodejs

I have a requirement to get all the dropdown options, and I need to iterate over these values ​​and submit the form. So I need a list of outliers.

The following code in java matches my exact requirement, but I need the same code in Javascript + selenium + Nodejs

Select select = new Select(driver.findElement(By.name("height")));
List list = select.getOptions();

Can this be done in nodejs + selenium + javascript

+4
source share
2 answers

For those who are stuck with this, they understand how I did it for the option:

<select id='mySelection'>
   <option value='0'>Hello</option>
   <option value='1'>Everybody</option>
   <option value='2'>Got</option>
   <option value='3'>It</option>
</select>

In Selenium for NodeJS, you would capture "This":

var webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder().
   withCapabilities(webdriver.Capabilities.chrome()).
   build();

driver.findElement(webdriver.By.id('mySelection')).sendKeys('3');

When you use .sendKeys () for an option, it should equal the value = ''

, sendKeys() .

-1

Cheerio -

module.exports = {
    "login": function (browser) {
        var cheerio = require("cheerio")

        browser
            .url("http://www.wikipedia.org")
            .waitForElementVisible('body', 1000)
            .waitForElementVisible('select#searchLanguage', 1000)
            .source(function(result) { // .source() dump the page source in the variable
                $ = cheerio.load(result.value)
                var num_languages = $('select#searchLanguage option').length
                console.log('Wikipedia.org Languages: ' + num_languages);
            })
            .end();
    }
};

. .

-3

All Articles