首页 文章

xpath:无法找到选择下拉列表

提问于
浏览
0

我得到以下例外,

无效的选择器:无法找到带有xpath表达式的元素//选择[@ name ='countryList,原因如下:SyntaxError:无法对'Document'执行'evaluate':字符串'// select [@name ='countryList'不是有效的XPath表达式 .

这是我的HTML代码,

<form method="post" action="/eClaims/app" name="itemEditForm" id="itemEditForm" class="itemEditForm" accept-charset="utf-8">
<div style="display:none;"><input type="hidden" name="formids" value="TextField,wdd">
<input type="hidden" name="component" value="ClaimItemDetail.itemEditForm">
<input type="hidden" name="page" value="ClaimItemPage">
<input type="hidden" name="service" value="direct">
<input type="hidden" name="session" value="T">
<input type="hidden" name="If_87" value="T">
<input type="hidden" name="For_3" value="ecfqwcqw">

</div>
    <input type="text" name="TextField" value="" id="requestKeyItemId" style="visibility: hidden">
    <!-- START ORDERED Item detail table  -->   
        <div name="mainClaimItemDetailDiv">
            <table width="100%" bgcolor="#cccccc">

            </table>            
            <!-- show item information section START -->
            <table width="100%" bgcolor="#cccccc">
                <tbody><tr bgcolor="silver">
                    <th>
                        HP Item Ref.
                    </th>

                    <th>
                        Estimated Value
                        (
                        AUD
                        )<br>
                    </th>

                        <th>
                            Country of Origin
                        </th>                                       
                        <th>
                            Serial #
                        </th>                   
                    <th>
                        Estimated Value($)
                    </th>
                    <th>
                        <input type="text" name="clmid" value="" id="clmid" style="visibility: hidden;">
                    </th>
                </tr>
                <tr width="100%" bgcolor="#cccccc">
                    <td align="center">
                        56730270
                    </td>

                    <td>
                        252.79
                    </td>                   
                        <td align="center">

                                <!--<span jwcid="countryList_1" onchange="javascript:checkIfDropdownValueNull(this);" ></span> -->
                                <select name="countryList_1" id="countryList_1" style="width:50px;">
<option value="">--please select--</option>
<option value="AF">AF</option>

<option value="ZW">ZW</option>
</select>
                        </td>


                        <td align="center">

                                <input type="text" name="serialNo_2" value="5CD6340S04" id="serialNo_2" maxl="10" onfocus="javascript:onProductFocus(this);" size="10" onblur="javascript:onItemDataChange(this,10)">                           
                        </td>

                    <td align="center">
                        187.06
                    </td>
                    <td align="center">
                        <input type="submit" name="Submit" id="fetchitemBtn" class="fetchitemBtn" style="visibility: hidden;">
                    </td>
                </tr>
            </tbody></table>    
</form>

到目前为止,我使用了以下定位器,

//select[contains(@id,'countryList_1')]

//select[@id,'countryList_1']

//**[@id="itemEditForm"]/div[@name='mainClaimItemDetailDiv']/table[2]/tbody/tr[2]/td[11]

//**[@id="itemEditForm"]/div[@name='mainClaimItemDetailDiv']/following::select[@id='countryList_1']

虽然,最后一个xpath没有找到任何元素 . 我已经使用了更多,但无济于事 .

请帮忙 .

提前致谢

1 回答

  • 0

    在代码中使用以下xpath它工作正常

    您可以关注以下任何xpath:

    //select[@id='countryList_1']
    
    //select[@name='countryList_1']
    
    //select[@id='countryList_1'][@name='countryList_1']
    
    //select[contains(@name,'countryList_1')]
    

    在您的错误日志中

    “字符串'// select [@ name ='countryList'不是有效的XPath表达式 . ”

    这意味着你的xpath不正确,你在xpath中有一些语法错误

相关问题