1

I am trying to click the image icon via xPath, but when I run the code the link present on image icon is not opening. Could you please help me in resolving this issue?

  • 1
    Would you mind providing the sample html where you got the problem identifying the element? – Rao Jun 23 '16 at 11:51
2

Maybe your xpath is wrong. You can use add-on FirePath for Firefox to get the xpath of the image. In order to let the link be clicked, your xpath should end with tag a, not img.

For example, suppose xpath of the image is .//*[@id='navbar_notice_6']/p/a/img, you should remove /img, then your command in java will be:

driver.findElement(By.xpath(".//*[@id='navbar_notice_6']/p/a")).click();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.