【问题标题】:how to get frost checkbox state using selenium如何使用硒获得霜复选框状态
【发布时间】:2017-01-08 21:32:55
【问题描述】:

我有一个霜复选框定义为:

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

我可以使用 selenium 对标签/输入执行单击操作,它选中/取消选中复选框,

但是,我必须得到它是否选中复选框的状态。

selected 复选框的属性在任何情况下都显示为 false。

【问题讨论】:

    标签: html selenium checkbox selenium-webdriver


    【解决方案1】:

    您可以尝试获取 checked 属性,即使它不存在于 html 中

    //C# syntax
    string checkedValue = checkBox.GetAttribute("checked");
    bool isChecked = checkedValue.Equals("true");
    

    【讨论】:

      猜你喜欢
      • 2017-12-17
      • 2017-05-12
      • 2011-09-06
      • 1970-01-01
      • 1970-01-01
      • 2016-12-13
      • 1970-01-01
      • 1970-01-01
      • 2015-07-15
      相关资源
      最近更新 更多