亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-99久久99久久-99久久99久久精品国产

您的位置:軟件測試 > 開源軟件測試 > 開源功能測試工具 > Selenium
Selenium Webdriver??處理Table
作者:網絡轉載 發布時間:[ 2016/8/16 14:07:51 ] 推薦標簽:功能測試工具 Selenium

  html table是由 table 元素以及一個或多個 tr、th 或 td 元素組成。如下:

  HTML源碼如下:
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>for selenium test </title>
</script>
</head>
<body>
<div align="center">
<h4 align="left">               table head:</h4>
<table border="2" width="90%" id="table138" bordercolorlight="#CCCCCC" cellspacing="0" cellpadding="0" bordercolordark="#CCCCCC" style="border-collapse: collapse">
<tr align="center">
<td height="26" width="10%" align="center" bgcolor="#CCEEAA" ><Strong>Test Case ID</Strong></td>
<td  height="26" width="35%" align="center" bgcolor="#EEEEAA" ><Strong>Steps</Strong></td>
<td  height="26" width="30%" align="center" bgcolor="#00EEEE" ><Strong>Expect</Strong></td>
<td  height="26" align="center" bgcolor="#EE00EE" ><Strong>Actual</Strong></td>
<td  height="26" align="center" bgcolor="#00EE00" ><Strong>PASS/FAIL</Strong></td>
</tr>
<tr align="center">
<td height="26" align="center" bgcolor="#CCEEAA">ENT#-12345</td>
<td  height="26" align="left" bgcolor="#EEEEAA" >1.open baidu.com ,wait for the page load</br>2.enter "selenium" in the input box" </br>3.click search button  </td>
<td  height="26" align="left" bgcolor="#00EEEE" >"Selenium - Web Browser Automation" link be the first of the search result</td>
<td  height="26" align="left" bgcolor="#EE00EE" >Selenium - Web Browser Automation is appear the page,but is not the first link</td>
<td  height="26" align="center" bgcolor="#00EE00" >FAIL</td>
</tr>
</tr>
<tr align="center">
<td height="26" align="center" bgcolor="#CCEEAA">ENT#-12346</td>
<td  height="26" align="left" bgcolor="#EEEEAA" >1.click the "Selenium - Web Browser Automation" link</br>2.wait for page load</td>
<td  height="26" align="left" bgcolor="#00EEEE" >open the official home page of selenium</td>
<td  height="26" align="left" bgcolor="#EE00EE" >selenium home page is load </td>
<td  height="26" align="center" bgcolor="#00EE00" >FAIl</td>
</tr>
</tr>
<tr align="center">
<td height="26" align="center" bgcolor="#CCEEAA">ENT#-12347</td>
<td  height="26" align="left" bgcolor="#EEEEAA" >1.click baidu snapshot of selenium web page </br>2. wait for the page load</td>
<td  height="26" align="left" bgcolor="#00EEEE" >the snapshot web page can be show up</td>
<td  height="26" align="left" bgcolor="#EE00EE" >the snapshot web page is show up</td>
<td  height="26" align="center" bgcolor="#00EE00" >PASS</td>
</tr>
</table>
</div>
</body>
</html>
  獲取table的base xpath,base xpath是指這個table的第n行第m列相同的部分,然后通過傳入n,m獲取返回值
  Java代碼:
public static String tableCell(WebDriver driver,int row, int column) {
String text = null;
//avoid get the head line of the table
//  row=row+1;
String xpath="//*[@id='table138']/tbody/tr["+row+"]/td["+column+"]";
try{
WebElement table=driver.findElement(By.xpath(xpath)); //*[@id="table138"]/tbody/tr[1]/td[1]/strong
text=table.getText();
}catch(NoSuchElementException e){
System.out.println("超出table邊界值");
}
return text;
}
  也可以通過 tr,td來寫
public static String tableCell2(WebDriver driver,int row, int column) {
String text = null;
//avoid get the head line of the table
//row=row+1;
try{
List<WebElement> rowCounts = driver.findElements(By.tagName("tr"));
WebElement currentRow = rowCounts.get(row-1);
List<WebElement> td = currentRow.findElements(By.tagName("td"));
WebElement cell = td.get(column-1);
text=cell.getText();
}catch(IndexOutOfBoundsException e){
System.out.println("超出table邊界值");
}
return text;
}

上一頁12下一頁
軟件測試工具 | 聯系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網站地圖
滬ICP備07036474 2003-2017 版權所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 亚洲免费福利 | 欧美高清在线精品一区 | 日本午夜三级 | 麻豆精品国产免费观看 | 成人短视频在线观看视频 | 国产在线视频国产永久视频 | 国产激情一级毛片久久久 | 男女视频在线观看免费高清观看 | 日韩高清免费在线观看 | 最近中文字幕在线观看 | 欧美日韩在线观看一区 | 亚洲va欧美va| 播播成人网 | 成人久久18免费网 | 成人免费www在线高清观看 | 国产日产欧产美一二三区 | 日本免费影院 | 在线天堂资源 | 波多野结衣资源在线观看 | 国产欧美亚洲精品第二区首页 | 亚洲精品乱码中文字幕无线 | 日韩精品一区二区三区在线观看 | 成人福利在线视频 | 午夜国产| 日日操网| 亚洲日本va中文字幕区 | 国产卡1卡2卡三卡网站免费 | 国产91精品久久久久久久 | 在线免费观看亚洲视频 | 精品成人免费一区二区在线播放 | 一级毛片在线免费播放 | 永久免费看的啪啪网站 | 97夜夜操 | 亚洲阿v天堂2021在线观看 | 老湿影院免费体验 | 成人久久18免费网 | 国产精品自在线拍国产 | 色欧美片视频在线观看 | 国产乱人伦偷精品视频不卡 | 男女边摸边吃奶边做视频在线 | 精品国产一区二区三区19 |