andreas
andreas

Reputation: 13

Webdriverio -- Elements doesn't work

I am trying to use Elements to get an array of elements, but it doesn't work here.

Any one can help me with that? thanks a lots.

here is my code:

<select name="test" id="select">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>

Now I am trying to get all the option elements:

client.url('www.somesite.com')
  .elements('#select>option').then(function(res){
       console.log(res.length);
    })

But I got 'undefined' result for 'res.length' .

If I use getText then I can get the correct result:

 client.url('www.somesite.com')
  .getText('#select>option').then(function(res){
       console.log(res.length);
    })

Upvotes: 1

Views: 939

Answers (1)

garajo
garajo

Reputation: 756

You need to access the value property.

console.log(res.value.length);

Upvotes: 2

Related Questions