【问题标题】:issue while finding the xpath for span located inside div/h2 inside document查找位于文档内 div/h2 内的 span 的 xpath 时出现问题
【发布时间】:2012-03-10 18:03:16
【问题描述】:

/* 回头客登录

    <h2>
        <label for="ctl00_Login2_UserName" id="ctl00_Login2_UserNameLabel">Email</label>

        <br />

        <input name="ctl00$Login2$UserName" type="text" value="pallavi@ensarm.com" maxlength="100" id="ctl00_Login2_UserName" class="formstyle2" style="width:150px;" />

        <span id="ctl00_Login2_UserNameRequired" title="User Name is required." style="color:Red;visibility:hidden;">*</span>

        <br />
        <br />

        <label for="ctl00_Login2_Password" id="ctl00_Login2_PasswordLabel">Password</label>

        <br />

        <input name="ctl00$Login2$Password" type="password" maxlength="100" id="ctl00_Login2_Password" class="formstyle2" style="width:150px;" />

        <span id="ctl00_Login2_PasswordRequired" title="Password is required." style="color:Red;visibility:hidden;">*</span>

        <a id="ctl00_Login2_ForgottenPasswordLink" href="ForgottenPassword.aspx">Forgotten password?</a>
    </h2>

    <h2 align="right">
        <span id="ctl00_Login2_FailureText" style="color:Red;">Your login attempt was not successful.  Please try again.</span>

        <div class="button_right button_fixedwidth">
            <a id="ctl00_Login2_ibnLogin" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$Login2$ibnLogin&quot;, &quot;&quot;, true, &quot;Login2&quot;, &quot;&quot;, false, true))">Login</a>
        </div>
    </h2>
</div>

*/

上面是我的 html 页面源,我想要跨度的 xpath 表达式,ID 为 ctl00_Login2_FailureText。位于 div/h2 内

我已经尝试了以下 xpath,但它不起作用: //span[@id='ctl00_Login2_FailureText' and contains(text(),'您的帐户已被暂时锁定,因为错误登录尝试的最大次数。')]

【问题讨论】:

  • span@id = 'ctl00_Login2_FailureText' 在提供的 XML 示例中不包含 Your account has been temporarily locked because of a maximum number of incorrect login attempts....

标签: xpath


【解决方案1】:

最好试试:

(将“text()”改为“.”)

//div/h2/span[@id='ctl00_Login2_FailureText' and contains(.,'Your account has been temporarily locked because of a maximum number of incorrect login attempts.')]

【讨论】:

    猜你喜欢
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-30
    • 2014-03-20
    • 2016-07-18
    • 2020-08-18
    • 2019-09-25
    • 1970-01-01
    相关资源
    最近更新 更多