如果这是正常选项或复选框控件我知道检查控件是否被选中或选中?但在这里我如何验证控件现在是“是”还是“否”状态?我已经附上了这个控件的html内容并请求帮助。
<div class="borrower-information__form-control switch-checkbox">
<input id="isAccountControllerAsPrimaryBorrower" class="toggle-checkbox ng-untouched ng-valid ng-not-empty ng-dirty ng-valid-parse" name="isAccountControllerAsPrimaryBorrower" data-ng-model="newController.controller.isAccountControllerAsPrimaryBorrower" aria-invalid="false" style="" type="checkbox"/>
<label for="isAccountControllerAsPrimaryBorrower" data-ng-attr-data-label="{{newController.booleanToString(newController.controller.isAccountControllerAsPrimaryBorrower)}}" data-label="Yes">Is primary borrower incapacitated?</label>
</div>
仅供参考...当我用firepath检查此控件时,它会突出显示标签标签(图中显示蓝色虚线)。
答案 0 :(得分:1)
WebElement webElement = //
String dataLabel = webElement.getAttribute("data-label");
boolean isChecked = dataLabel.equals("Yes") ? true : false;