需要
测试
的网页用firefox查看如下
如果需要点击select控件,选择其中某个菜单,然后点击查询按钮,代码如下
Select asnselect=new Select(driver.findElement(By.xpath("//form[@id='searchForm' and @name='searchForm']/table/tbody/tr/td[4]/select")));
asnselect.selectByIndex(1);
driver.findElement(By.id("searchForm.:btnQuery")).click();
<formid="searchForm"enctype="application/x-www-form-urlencoded"action="/receive/asnList.xhtml"method="post"name="searchForm">
<inputtype="hidden"value="searchForm"name="searchForm">
<tablewidth="100%">
<tbody>
<tr>
<td>
<td>
<inputtype="text"style="width:118px"onblur="return ValidTextAreaLength(this,'30');"maxlength="30"name="searchForm.:j_id232">
</td>
<td>
<td>
<selectstyle="width:118px"size="1"name="searchForm.:j_id236">
<optionselected="selected"value="">-请选择-</option>
<optionvalue="1">1</option>
<optionvalue="2">2</option>
<optionvalue="3">3</option>
</select>
</td>
|
如果需要点击select控件,选择其中某个菜单,然后点击查询按钮,代码如下
Select asnselect=new Select(driver.findElement(By.xpath("//form[@id='searchForm' and @name='searchForm']/table/tbody/tr/td[4]/select")));
asnselect.selectByIndex(1);
driver.findElement(By.id("searchForm.:btnQuery")).click();