mmar
mmar

Reputation: 2020

How to check a label is checked or not with option

I have a option which is in label control itself in Angular application. When No selected

When Yes selected

If this is an normal option or checkbox controls i know to check if the control is checked or selected? but here how i can verify if the control is now in 'Yes' or 'No' state? I have enclosed the html content for this control and plese help me.

<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>

FYI... when i inspected this control with firepath, it highlights the label tag (blue dashed lines show in the picture).

Upvotes: 0

Views: 164

Answers (1)

Grzegorz G&#243;rkiewicz
Grzegorz G&#243;rkiewicz

Reputation: 4596

WebElement webElement = //
String dataLabel = webElement.getAttribute("data-label");
boolean isChecked = dataLabel.equals("Yes") ? true : false;

Upvotes: 1

Related Questions