【问题标题】:Codeception radio button listCodeception 单选按钮列表
【发布时间】:2016-03-15 19:11:02
【问题描述】:

我有一个

形式的单选按钮列表
<div data-toggle="buttons" style="margin: 5px 0 20px">
     <label class="btn grey"><input type="radio" name="ResponseForm[nps]" value="0"> 0</label>
     <label class="btn grey"><input type="radio" name="ResponseForm[nps]" value="1"> 1</label>
     <label class="btn grey"><input type="radio" name="ResponseForm[nps]" value="2"> 2</label>
     <label class="btn grey"><input type="radio" name="ResponseForm[nps]" value="3"> 3</label>
     <label class="btn grey"><input type="radio" name="ResponseForm[nps]" value="4"> 4</label>
     <label class="btn grey"><input type="radio" name="ResponseForm[nps]" value="5"> 5</label>
     <label class="btn grey"><input type="radio" name="ResponseForm[nps]" value="6"> 6</label>
     <label class="btn grey active"><input type="radio" name="ResponseForm[nps]" value="7" checked=""> 7</label>
     <label class="btn grey"><input type="radio" name="ResponseForm[nps]" value="8"> 8</label>
     <label class="btn grey"><input type="radio" name="ResponseForm[nps]" value="9"> 9</label>
     <label class="btn grey"><input type="radio" name="ResponseForm[nps]" value="10"> 10</label>
</div>

当我尝试检查是否选择了收音机时

    ::canSeeOptionsIsSelected('form input[type=radio]', 1);

它正在抛出一个错误:

 Step  I can see option is selected "form input[type=radio]",1
 Fail  Element located either by name, CSS or XPath element with 'selected option' was not found.

据我了解,它正在寻找选择标签,而不是单选按钮。如果这不是检查是否选择了收音机的正确方法,那是什么?

【问题讨论】:

    标签: yii2 radiobuttonlist codeception


    【解决方案1】:

    您的选择器似乎格式错误,因为您没有在 HTML 文件中使用 form 标记。也许可以尝试一个 xpath,例如://input[@type='radio'] in canSeeOptionsIsSelected() 函数

    【讨论】:

    • 我只是没有粘贴到这里。如果我调用 ::amOnPage(); 代码工作正常; TWICE,这很奇怪。
    猜你喜欢
    • 2017-09-05
    • 1970-01-01
    • 1970-01-01
    • 2017-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多