如何在量角器中设置单选按钮值 [英] how to set a radio button value in protractor
问题描述
我是 Protractor 的新手,我正在尝试使用 Protractor 设置单选按钮值.我在互联网和 SO 上搜索了徒劳的答案.
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>
从上面的 html 文件中,我尝试在我的 jasmine it() 中执行时设置 No/Yes/Maybe,并使用如下所示的一些量角器代码:
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();
对于上面的代码,它默认只接受 yes.我想专门设置单选组的任何值,即 child(md-radio-button) 像父级的 Yes/No/Maybe(md-radio-grp).我尝试了很多方法,比如绑定、地图等,但没有任何帮助.寻求帮助.提前致谢.
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.
推荐答案
尝试:
element(by.id('radiogrp1')).all(by.tagName('md-radio-button')).get(0).click();
这篇关于如何在量角器中设置单选按钮值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!