【问题标题】:Behat step definition to verify whether the radio button is checkedBehat 步骤定义以验证单选按钮是否被选中
【发布时间】:2017-09-07 14:31:52
【问题描述】:

我想写一个步骤定义来验证一个单选按钮是否被选中。 每个单选按钮都有一个关联的标签:-“是”或“否”

输入标签内的单选按钮名称与与特定单选按钮关联的标签相同

HTML 结构:

<label>
    <input type= "radio" name="subscribe_list" value="1" 
    checked="checked">
    :: before
    </input>
    "Yes"
</label>
<label>
    <input type= "radio" name="subscribe_list" value="1" 
    checked="checked">
    </input>
    "No"
<label>

例如:订阅列表:是 没有

像上面的例子一样,有多个单选按钮,每个按钮都有一个“是”或“否”标签

我想编写一个函数来检查是否为特定单选按钮名称检查了“是”或“否”。我应该如何实现这个? 提前致谢!

【问题讨论】:

    标签: php bdd behat gherkin mink


    【解决方案1】:

    您可以使用 Behat 的现有步骤之一,也可以实施自己的步骤。

    现有步骤:

    the "my_checkbox_identifier" checkbox should be checked

    如果您能够使用field id|name|label|value 识别复选框(输入),这将起作用。

    要实现与选择器一起使用的自定义步骤,您需要首先通过现有的 find 方法找到元素并在返回的节点上使用 isChecked(),然后在需要时使用异常/断言使该步骤失败。

    【讨论】:

      猜你喜欢
      • 2019-08-30
      • 2021-12-03
      • 2013-10-02
      • 2012-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-11
      • 1970-01-01
      相关资源
      最近更新 更多