javascript - Using Dalekjs test tool, how to select Option in Dropdown(Select element) when there is no "value" attribute in Option tag? -


lets consider below "select" example "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 select option using below code,

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

but, when above example don't have "value" attribute show below,

<select onchange="fruitselected();" id="fruitid"> <option></option> <option>apple</option> <option>mango</option> <option>banana</option> </select>; 

how select option dropdown?

i tried using .execute below,

.execute(function () {     document.getelementbyid("fruitid").selectedindex = "1"; }) 

i'm able select option apple, onchange function not getting called.

how select option dropdown? onchange function can b called.

note: select tag cannot modified, i'm testing.

thanks in advance..

i did more r&d , found above situation can solved using .setvalue() below

.setvalue('#fruitid','apple') 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -