我想selenium webdriver點擊這個鏈接,所以我可以繼續我的項目。這是我的代碼。沒有錯誤,但沒有點擊鏈接。Selenium不會點擊,無名稱,ID或類
x = driver.find_element_by_xpath('/html/body/table[2]/tbody/tr[2]/td/span/
a[7]')
x.click()
下面是HTML
<tr>
<td width="100%">
<span style="white-space: nowrap">
<a href="#">
<img src="https://staffmate.com/imagessm/OEA_sm_lt.gif" border="0" width="125" height="36">
</a>
<a href="#">
<img src="https://staffmate.com/imagessm/OPOS_sm_lt.gif" border="0" width="125" height="36">
</a>
<a href="#">
<img src="https://staffmate.com/imagessm/OCTR_sm_lt.gif" border="0" width="125" height="36">
</a>
<a href="#">
<img src="https://staffmate.com/imagessm/OCL_sm_lt.gif" border="0" width="125" height="36">
</a>
<a href="#">
<img src="https://staffmate.com/imagessm/OVEN_sm_lt.gif" border="0" width="125" height="36">
</a>
<a href="#">
<img src="https://staffmate.com/imagessm/OEV_sm_dk.gif" border="0" width="125" height="36">
</a>
<a href="eprintreports.php?eSessID=199495633810875522501415473608154261624185901388039708769020171218111124">
<img src="https://staffmate.com/imagessm/PREP_sm_lt.gif" border="0" width="125" height="36">
</a>
</span>
</td>
</tr>
我想點擊鏈接第七。我從Chrome的檢測工具中直接複製了xpath。我知道一個絕對的xpath是不可靠的,但是當沒有類名,id或者名字時我還有什麼可用的?幫助將不勝感激。
可以共享URL? –
我已添加網址 – Cameron
該網址似乎仍然不是描述中,請添加它,這樣我們可以幫助進一步 – Danny