元素应为“ select”元素,但在硒中为“ span”元素

纳加朱纳·雷迪(Nagarjuna Reddy)

切换按钮存在于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;

使用硒运行时出现错误

org.openqa.selenium.support.ui.UnexpectedTagNameException:元素应为“选择”但为“跨度”

如何解决这个问题。如果需要更多详细信息,请提出建议。

称赞

我没有看到与您的选择器匹配的任何元素,您应该使用label而不是a,例如:

label.cb-enable.selected


label.cb-disable.selected

或使用基于输入的选择器。意味着链接,您没有任何链接。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章