2017-02-09 93 views
0

我有一個在Angular應用程序中的標籤控制本身的選項。 When No selected如何檢查標籤是否被選中

When Yes selected

如果這是一個正常的選項或CheckBox控件我知道要檢查控制檢查或選擇?但在這裏我可以驗證如果控件現在處於「是」或「否」狀態?我已經附上了這個控件的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> 

FYI ...當我檢查與firepath這種控制,突出了標籤標記(藍色虛線顯示在圖片)。

+0

我想你的意思是JavaScript不是Java,不是嗎? – Thomas

+0

我在黃瓜,爪哇,硒... – mmar

回答

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

是的。正是我所需要的,並且能夠進一步發展。非常感謝。 – mmar