使用 C# (.Net) 为 FF/IE 使用 Selenium Webdriver
下面是我的页面源代码,我正在尝试使用 CssSelector 从我的页面中查找/包含特定名称,我尝试使用以下代码但导致错误,有什么帮助吗?
//代码
driver.FindElement(By.CssSelector("td:contains('John John')"))
//错误:
e {"Unable to find element with css selector == td:contains('John John')"} System.Exception {OpenQA.Selenium.NoSuchElementException}
//我的html代码:
<div id="ctl00_ContentPlaceHolder1_AddeCardControl1_gv_ctl01_RecordCount" style="float:right; padding-right:10px; margin-top:3px;">
<b>308</b> Items Found
</div>
</td>
</tr>
<tr class="item">
<td align="center"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$AddControl1$gv','Select$0')">Edit</a></td>
<td align="center" style="width:15px;"></td>
<td>John John</td>
<td> </td>
<td> </td>
<td> </td>
<td><img src="check.png" alt='Active' style='display: ;' /></td>
<td>9/7/2012 11:15:08 PM</td>
</tr>
<tr class="altItem">
<td align="center"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$AddControl1$gv','Select$1')">Edit</a></td>
<td align="center" style="width:15px;"></td>
<td>John Schulz</td>
<td> </td>
<td>Visitors</td>
<td> </td>
<td><img src="check.png" alt='Active' style='display: ;' /></td>
<td>9/7/2012 6:28:29 PM</td>
</tr>
<tr class="item">
<td align="center"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$AddControl1$gv','Select$2')">Edit</a></td>
<td align="center" style="width:15px;"></td>
<td>Parker Smith</td>
<td> </td>
<td>Visitors</td>
<td> </td>
<td><img src="check.png" alt='Active' style='display: ;' /></td>
<td>9/7/2012 6:01:28 PM</td>
</tr>
<tr class="altItem">
<td align="center"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$AddControl1$gv','Select$3')">Edit</a></td>
<td align="center" style="width:15px;"></td>
<td>Test 123</td>
<td> </td>
<td>Visitors</td>
<td> </td>
<td><img src="check.png" alt='Active' style='display: ;' /></td>
<td>9/7/2012 1:36:45 PM</td>
</tr>
<tr class="item">
<td align="center"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$AddControl1$gv','Select$4')">Edit</a></td>
<td align="center" style="width:15px;">