切换按钮出现在类似于
的Web应用程序中http://www.dhtmlgoodies.com/index.html?whichScript=on-off-switch
在上述链接中搜索“选项二”。
关闭时,按钮的Html代码如下所示
<div class="field-block button-height">
<label style="width:175px" class="label" for="input-2"><b>Case Association</b><sup>*</sup>
<span id="reqCaseAssociationTD" style="display: none;">
required</span>
</label>
<p style="margin:0px" class="field switch">
<label style="margin:0 0 4px" class="cb-enable"><span>On</span></label>
<label style="margin:0 0 4px" class="cb-disable selected"><span>Off</span></label>
<input type="checkbox" class="checkbox" id="caseAssociation">
</p>
<span style="margin-top:8px;margin-left:2px" data-tooltip="Simulataneous post from the same user (Twitter and Facebook) would get associated with the previous open case of the user." class="helpText showToolTip"></span>
</div>
按钮的Html代码在打开时是这样的
<div class="field-block button-height">
<label style="width:175px" class="label" for="input-2"><b>Case Association</b><sup>*</sup>
<span id="reqCaseAssociationTD" style="display: none;">
required</span>
</label>
<p style="margin:0px" class="field switch">
<label style="margin:0 0 4px" class="cb-enable selected"><span>On</span></label>
<label style="margin:0 0 4px" class="cb-disable"><span>Off</span></label>
<input type="checkbox" class="checkbox" id="caseAssociation" checked="checked">
</p>
<span style="margin-top:8px;margin-left:2px" data-tooltip="Simulataneous post from the same user (Twitter and Facebook) would get associated with the previous open case of the user." class="helpText showToolTip"></span>
</div>
使用以下标识符
//Case Association Turned On
@FindAll(@FindBy(how = How.CSS, using = "a.cb-enable.selected"))
public List<WebElement> caseAssociationIsON;
//Case Association Turned OFF
@FindAll(@FindBy(how = How.CSS, using = "a.cb-disable.selected"))
public List<WebElement> caseAssociationIsOFF;
使用selenium运行时遇到错误
org.openqa.selenium.support.ui.UnexpectedTagNameException:Element 应该是“选择”但是“跨度”
如何解决这个问题。如果需要更多详细信息,请提出建议。
答案 0 :(得分:0)
我没有看到任何与您的选择器匹配的元素,您应该使用label
代替a
,例如:
label.cb-enable.selected
和
label.cb-disable.selected
或使用基于输入的选择器。一个手段链接,你没有任何。
答案 1 :(得分:0)