Here is my HTMLCode:

<span onclick="cart_delete('0')">
<i class="fa fa-trash-o" aria-hidden="true"></i>

I tried with below code:


Please help to click on delete icon using Selenium.

  • add code trial by you and error as well – NarendraR Sep 28 '18 at 7:50
  • What is the error that you are getting. – Alok Sep 29 '18 at 17:34

Try this code

driver.findElement(By.xpath("//i[@class='fa fa-trash-o']")).click();

| improve this answer | |
  • 1
    whats wrong with it Mane ? – John snow Sep 28 '18 at 9:22
  • Sorry I was not downvoted to your answer. I know this would be the solution. I just tried formatting code in a good shape... that's it. – Bharat Mane Sep 28 '18 at 10:52

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.