下面是代碼:我如何點擊Selenium中的這個href鏈接?
<div class="padding">
<a href="javascript:FreshCoShowEFlyerOverlay()">
<img alt="Example" src="http://freshco.wpengine.com/wp-content/uploads/2015/05/week-flyer-left.jpg" height="158" width="280">
</a>
</div>
我想點擊的href。我曾經試過,但它不工作:
driver.findElement(By.xpath("//href[text()='javascript:FreshCoShowEFlyerOverlay']")).click();
你這是什麼意思是_it不工作_?你有錯誤嗎?什麼都沒有發生? – Keppil
'href'不是標籤,而是屬性。 –
它拋出org.openqa.selenium.NoSuchElementException –