I want to find the element for a checkbox on the page:
this is the source code of the page:
<tr>
<td class="tablecell" width="200" valign="top">Filter_list</td>
<td class="tablecell" width="360">
<div id="div_filterlist">
<table border="0">
<tr>
<td class="tablecell" width="160" valign="top"><b>Available Filters</b><br>
<ul id="unselected_ilters" class="unselected_filter">
<li itemID="test">
<input type="checkbox" value="test" onClick="toggleUnselected(this,'test')" onMouseOver="this.style.cursor='hand'"/>
<a href="#" onClick="document.filterform.name.value='test';document.filterform.submit();">test</a>
</li>
My code is not working:
String xpathLocater = "//input[ @type=\"checkbox\" and @value=\" test\"]";
答案 0 :(得分:1)
css selector:
String cssLocator = "input[type=checkbox]";
or
String cssLocator = "input[type=checkbox][value=test]";
xpath selector:
String xpathLocator = "//input[@type=\"checkbox\"]";
or
String xpathLocator = "//input[@type=\"checkbox\" and @value=\"test\"]";
If you still can't find the element check 2 things: