我有以下的html頁面源,我嘗試通過xpath/cssselector單擊圖像。沒有人可以工作,你能幫我找到我的代碼問題嗎?我使用IE9。如何點擊selenium webdriver的圖片鏈接?
<pretable border="0" cellpadding="0" cellspacing="0" width="700">
<tr>
<td rowspan="2" width="120">
<a href="#" onclick="oCMenu.m['top1'].b.moveIt(8,60); oCMenu.showsub('top1'); "
onclick="return false" class="FontNormal">
<img border="0" src="images/shim.gif" width="112" height="73"></a></td>
</tr>
</pretable>
我的代碼是:
ieDriver.findElement(By.xpath("//html/table/tr[1]/td/a[@class='FontNormal']/img[@src='images
/shim.gif']")).click();
ieDriver.findElement(By.cssselector("class='FontNormal'")).click();
代碼塊不提供一個很好的答案。請添加解釋(爲什麼它解決了問題,錯誤在哪裏等) – 2016-01-11 20:50:53