Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set a radio button value in protractor

Tags:

protractor

I'm new to Protractor, I'm trying to set the radio button value using Protractor. I searched over the internet and the SO for the answers which went vain.

html:

<md-radio-group
            id="radiogrp1"
            name="radiogrp1"
            ng-model="application.myRadioGrp"                
            required>
        <md-radio-button value="N" aria-label="No">No</md-radio-button>
        <md-radio-button value="Y" aria-label="Yes">Yes</md-radio-button>
        <md-radio-button value="M" aria-label="Maybe">May</md-radio-button>
</md-radio-group>

From the above html file, I tried to set No/Yes/Maybe while executing in my jasmine it() with some Protractor code like shown below:

element.all(by.id('radiogrp1)).get(0).click();

For this above code it default accepts yes alone. I want specifically set any value of radio group i.e., child(md-radio-button) like Yes/No/Maybe of parent(md-radio-grp). I tried in many ways like bind, map etc., but nothing helped really. Looking for help. Thanks in advance.

like image 313
vsm Avatar asked Jan 09 '15 17:01

vsm


1 Answers

Try:

element(by.id('radiogrp1')).all(by.tagName('md-radio-button')).get(0).click();
like image 138
hankduan Avatar answered Oct 03 '22 17:10

hankduan