我需要有关量角器代码的帮助来检查两个单选按钮(是和否)是否存在。
对于是和没有单选按钮,HTML看起来像这样
<input required="required"
class="ng-touched ng-valid ng-valid-required ng-dirty ng-valid-parse"
name="dangerousGood" id="dangerousGoodNo" data-ng-model="SLI.dangerous"
value="false" data-ng-required="true"
ng-change="updateCommodityType('N');isSrvLvlHazmat();errorMsgOnScreen.msg2 = false;"
type="radio">
<input required="required"
class="ng-dirty ng-valid ng-valid-required ng-touched"
name="dangerousGood" data-ng-model="SLI.dangerous"
value="true" data-ng-required="true"
ng-change="updateCommodityType('Y');isSrvLvlHazmat();"
type="radio">
答案 0 :(得分:1)
如果是在线状态而非可见性,则需要检查,只需使用element.all()
查找两个输入并检查count()
:
var checkboxes = element.all(by.name("dangerousGood"));
expect(checkboxes.count()).toEqual(2);
您还可以使用by.model()
locator:
var checkboxes = element.all(by.model("SLI.dangerous"));
您还可以单独找到这两个复选框,断言状态/可见性并默认检查按钮is selected:
var yesRadioButton = $("input[name=dangerousGood]:not(#dangerousGoodNo)");
var noRadioButton = $("input#dangerousGoodNo");
expect(yesRadioButton.isDisplayed()).toBe(true);
expect(noRadioButton.isDisplayed()).toBe(true);
expect(yesRadioButton.isSelected()).toBe(true);
expect(noRadioButton.isSelected()).toBe(false);