【发布时间】:2015-07-20 17:43:16
【问题描述】:
代码如下:
<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();
【问题讨论】:
-
你说的不起作用是什么意思?你有错误吗?什么都没有发生吗?
-
href不是标签,而是属性。 -
它抛出 org.openqa.selenium.NoSuchElementException
标签: java html selenium selenium-webdriver webdriver