html部分代码如下:
- <tbody>
- <tr class="odd">
- <td>1609</td>
- <td>-YOUKU-begin</td>
- <td>firstAgent</td>
- <td> </td>
- <td> </td>
- <td>2015-09-16 17:02:55</td>
- <td><span class="stop" ref="1609" id="change_status"></span>stop </td>
- <td class="mtbuttons"><a href="javascript:;">permission</a> | <a href="/code/index.php?r=update&id=1609">edit</a> </td>
- </tr>
- <tr class="even selected">
- <td>1594</td>
- <td>-YOUKU</td>
- <td>firstAgent</td>
- <td> </td>
- <td> </td>
- <td>2015-09-16 17:02:55</td>
- <td><span class="stop" ref="1594" id="change_status"></span>stop </td>
- <td class="mtbuttons"><a href="javascript:;">permission</a> | <a href="/code/index.php?r=update&id=1594">edit</a> </td>
- </tr>
- <tr class="odd">
- <td>1593</td>
- <td>-YOUKU-first</td>
- <td>firstAgent</td>
- <td> </td>
- <td> </td>
- <td>2015-09-16 17:02:55</td>
- <td><span class="stop" ref="1593" id="change_status"></span>stop </td>
- <td class="mtbuttons"><a href="javascript:;">permission</a> | <a href="/code/index.php?r=update&id=1593">edit</a> </td>
- </tr>
- </tbody>
找到列中有1594这个值的行,然后点击edit链接
- List<WebElement> trlist=driver.findElements(By.xpath("//div[@id='company-grid']/table/tbody/tr"));
- for(int r=0;r<trlist.size();r++){
- String trText=trlist.get(r).getText();
- if(trText.contains("1594")){
- trlist.get(r).findElement(By.xpath("(.//a[contains(text(),'edit')])[2]")).click();
- break;
- }
- }