Reputation: 119
I am getting the following exceptions,
invalid selector: Unable to locate an element with the xpath expression //select[@name='countryList because of the following error: SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//select[@name='countryList' is not a valid XPath expression.
Here is my html code,
<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>
So far i have used the following locators,
//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']
Although, the last xpath is not locating any element. I have used many more but to no avail.
please help.
Thanks in advance
Upvotes: 0
Views: 1911
Reputation: 257
your xpath is missing an ']'. use correct xpath as shown below
//select[@name='countryList']
Upvotes: 0
Reputation: 4749
Use following xpath in your code it is working fine
You can follow any of these xpaths:
//select[@id='countryList_1']
//select[@name='countryList_1']
//select[@id='countryList_1'][@name='countryList_1']
//select[contains(@name,'countryList_1')]
In your error log
"The string '//select[@name='countryList' is not a valid XPath expression."
that means your xpath is not correct, you have some syntax error in xpath
Upvotes: 0