Reputation: 1
<a href="/index.php/leave/assignLeave" target="_self" xpath="1">
<img src="/webres_5acde3dbd3adc6.90334155/orangehrmLeavePlugin/images/ApplyLeave.png" style="">
</a>
I am getting an error:
"no such element: Unable to locate element: {"method":"css
selector","selector":"a[src='webres_5acde3dbd3adc6.90334155/orangehrmLeavePlugin/images/ApplyLeave.png']"}"
Upvotes: 0
Views: 2478
Reputation: 193128
@NarendraR's answer was in the right direction. However the value of the src attribute i.e. /webres_5acde3dbd3adc6.90334155/orangehrmLeavePlugin/images/ApplyLeave.png looks dynamic to me. So you can use either of the following solutions:
cssSelector
:
driver.findElement(By.cssSelector("a[href*='assignLeave']>[src*='ApplyLeave']")).click();
xpath
:
driver.findElement(By.xpath("//a[contains(@href,'assignLeave')]/img[contains(@src,'ApplyLeave')]")).click();
Upvotes: 0
Reputation: 7708
You should try <img>
tag instead of <a>
because src
is attribute of <img>
CSS
img[src='/webres_5acde3dbd3adc6.90334155/orangehrmLeavePlugin/images/ApplyLeave.png']
Upvotes: 2