I am unable to click on logout link in my web page using XPath.

XPath: html/body/div[1]/span/div[1]/a[1]

I See my code in an attachment:

my Code .

HTML Script for "logout"

  • //a[contains(text(),'[Logout]')] - This XPath will definitely works for you. – Bharat Mane Jun 29 '18 at 11:25
  • Try to wait for the webelement by using WebDriverWait class. – Alok Jul 1 '18 at 7:07

Switch to the iframe first, for that try the below code.


After that you can use the XPath or CSS selector to identify the locator.

css: a[onclick*=exitAction]

xpath: //a[contains(@onclick, 'exitAction')]

| improve this answer | |

Try with the below xpath.

| improve this answer | |

Try this below XPath.


Prefer Relative XPath rather than Absolute XPath.

| improve this answer | |

Try the below code using LinkText locator for locating the logout button.

| improve this answer | |

Try this below code.


This should also work.

| improve this answer | |

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.