这里是HTML代码示例:硒的webdriver:排除子节点
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<tr class="tinyfont">
<tr height="2px">
<tr height="1px">
<tr height="1px">
<tr>
<tr height="2px">
<tr height="1px">
<tr height="1px">
<tr height="2px">
</tbody>
</table>
我使用硒的webdriver。 我已经收到了这段代码中的所有子元素,但现在我想在逻辑中排除一个特定的子元素,我如何从我的数组中排除其中一个子元素。 我想排除tr [6]子元素..
List<WebElement> list = driver.findElements(By.xpath("/html/body/table/tbody //*"));
ArrayList<String> al1 = new ArrayList<String>();
for(WebElement ele:list){
String className = ele.getAttribute("class");
System.out.println("Class name = "+className);
al1.add(className);
}
在此先感谢!
我想这可能是你要找的东西? http://stackoverflow.com/questions/7115917/xpath-select-node-but-not-specific-child-elements – Richard
没有与硒webdriver工作.. – user3107875
你想排除哪个元素?您正在使用的html样本将有所帮助。 –