1

Lets consider below "Select" example with "value" attribute,

<select onchange="fruitSelected();" id="">
<option value=""></option>
<option value="apple">apple</option>
<option value="mango">mango</option>
<option value="banana">banana</option>
</select>

Using dalekjs I'm able to select the option using below code,

.click('#moduleType option[value="apple"]')

But, when the above example don't have "value" attribute as show below,

<select onchange="fruitSelected();" id="fruitID">
<option></option>
<option>apple</option>
<option>mango</option>
<option>banana</option>
</select>;

How to select option from dropdown?

I tried using .execute as below,

.execute(function () {
    document.getElementById("fruitID").selectedIndex = "1";
})

I'm able to select option as apple, but onchange function is not getting called.

How to select option from dropdown? so that onchange function also can b called.

NOTE: Select tag cannot be modified, as I'm just testing.

Thanks in Advance..

Hardik H
  • 21
  • 2

1 Answers1

1

I did more R&D and found that the above situation can be solved by using .setvalue() as below

.setValue('#fruitID','apple')
Hardik H
  • 21
  • 2