I have a frost checkbox defined as :
<div id="protocol_input" class="ember-view frost-checkbox small">
<input id="protocol_input" class="input ember-view" type="checkbox">
<label class="label" tabindex="0" for="protocol_input">
Enable protocol
<svg xmlns="http://www.w3.org/2000/svg" viewBox="3 2 31 31">
<rect xmlns="http://www.w3.org/2000/svg" x="10.7" y="15.3" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 35.6974 26.188)" fill="%23009EEF" width="3.5" height="10.3">
<polygon xmlns="http://www.w3.org/2000/svg" fill="%23009EEF" points="14.9,25.4 12.4,22.9 26.2,9.4 28.7,12.1">
</svg>
</label>
</div>
I can perform click operation on the label/input using selenium, which checks/unchecks the checkbox,
But, I have to get its state that whether checkbox selected or not.
selected property for checkbox is showing false in any of the case.
答案 0 :(得分:0)
即使html中没有checked
属性,您也可以尝试获取该属性
//C# syntax
string checkedValue = checkBox.GetAttribute("checked");
bool isChecked = checkedValue.Equals("true");