0

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
3

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

driver.switchTo().frame(driver.findElement(By.cssSelector("iframe[src*=sfactory]")));

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 | |
1

Try with the below xpath.

//a[contains(text(),'Logout')] 
| improve this answer | |
0

Try this below XPath.

//a[contains(text(),'[Logout]')]

Prefer Relative XPath rather than Absolute XPath.

| improve this answer | |
0

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

driver.findElementBy.linkText("[Logout]")
| improve this answer | |
0

Try this below code.

//a[contains(.,'Logout')]

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.