I am trying to find out XPath for this "Sign Out" button, can anyone help me?
There are much better ways to locate the element aside from using XPath, don't focus on XPath too much - this is, generally speaking, the slowest and the least readable way to locate elements.
I would locate the element by the link text instead, example in Protractor/WebDriverJS:
Example in Java:
First of all, copy the XPath by right-clicking the highlighted text in the pane on the right that you've shown, then selecting Copy > Copy XPath. You can then see what the XPath is by pasting it in an appropriate location (e.g. a text editor window).
In addition to above solution of using link text in our automation testing company, we have used xpath as below that may help you as well
1. //div//a[contains(text,'Sign Out')] 2. //div//a[text='Sign Out']
Try this one.
driver.findElement(By.xpath("//a [@href = '/bgstorefront/bgb2b/em/logout' and @title = 'Sign out']")).click();