Protractor 量角器检查是否选择了元素

Protractor 量角器检查是否选择了元素,protractor,Protractor,我有3个按钮,html是: <label class="label-text btn btn-primary active ng-dirty ng-valid-parse" btn-radio="thisDateType.value" ng-model="controller.formData.dateType" value="disputeDate" name="dateType" ng-class="{active:thisDateType.id==controller.dateTyp

我有3个按钮,html是:

<label class="label-text btn btn-primary active ng-dirty ng-valid-parse" btn-radio="thisDateType.value" ng-model="controller.formData.dateType" value="disputeDate" name="dateType" ng-class="{active:thisDateType.id==controller.dateTypeSelect.radioModel.id}" ng-repeat="thisDateType in controller.dateTypeSelect.dateType">Dispute Date</label>
<!-- end ngRepeat: thisDateType in controller.dateTypeSelect.dateType -->
<label class="label-text btn btn-primary ng-dirty" btn-radio="thisDateType.value" ng-model="controller.formData.dateType" value="respondByDate" name="dateType" ng-class="{active:thisDateType.id==controller.dateTypeSelect.radioModel.id}" ng-repeat="thisDateType in controller.dateTypeSelect.dateType">Respond By Date</label>
<!-- end ngRepeat: thisDateType in controller.dateTypeSelect.dateType -->
<label class="label-text btn btn-primary" btn-radio="thisDateType.value" ng-model="controller.formData.dateType" value="slaDate" name="dateType" ng-class="{active:thisDateType.id==controller.dateTypeSelect.radioModel.id}" ng-repeat="thisDateType in controller.dateTypeSelect.dateType">SLA Date</label>
<!-- end ngRepeat: thisDateType in controller.dateTypeSelect.dateType -->
然而,量角器不断计算DisputterateButton.isSelected()为false。我已经仔细检查了我的元素定位器xpath,它是正确的。我这样做是对的还是有其他方法可以使用

element.all(by.repeater("thisDateType")).then(function(buttonArray) {
    expect(buttonArray[0].getAttribute('class')).toBe('label-text btn btn-primary active');
});

由于类值会根据所选内容而变化,因此我决定对其进行评估,这样做是可行的

您能否共享
搜索页面的标识符。DisputterateButton
。这些按钮是库插件的一部分。正因为如此,我不得不和别人一起工作。除了我提供的数组位置之外,没有任何方法可以专门定位该元素。您可以使用该方法来标识DisputterateButton。
element.all(by.repeater("thisDateType")).then(function(buttonArray) {
    expect(buttonArray[0].getAttribute('class')).toBe('label-text btn btn-primary active');
});