Reputation: 141
Here is the code:
<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>
I am trying to click on the href. I have tried this but it does not work:
driver.findElement(By.xpath("//href[text()='javascript:FreshCoShowEFlyerOverlay']")).click();
Upvotes: 0
Views: 750
Reputation: 181
As another variant:
driver.findElement(By.CssSelector("a[href*='FreshCoShowEFlyerOverlay']")).click();
Upvotes: 0
Reputation: 2608
Use this:
driver.findElement(By.xpath("//a[@href='javascript:FreshCoShowEFlyerOverlay']")).click();
Intead of:
driver.findElement(By.xpath("//href[text()='javascript:FreshCoShowEFlyerOverlay']")).click();
Upvotes: 2