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')]


Try with the below xpath.


Try this below XPath.


Prefer Relative XPath rather than Absolute XPath.


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


Try this below code.


This should also work.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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