Problem in clicking on icon



  • 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?



  • 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();
    

Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2