Q:

The given selector Comments button is either invalid or does not result in a WebElement

My Selenium server generates following error when trying to access a dom element with Xpath //*[@id="someid"]/div/div/div/a.   
WARN - Exception: The given selector Comments button is either invalid or does not result in a WebElement. The following error occurred:
InvalidSelectorError: Unable to locate an element with the xpath expression Comments button because of the following error:
SyntaxError: The expression is not a legal expression.
For documentation on this error, please visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html

This XPath works fine with Firefox when used in console but fails when running Automated test with Selenium Hq + Facebook Webdriver, with above exception of course.
What could be wrong since the Xpath seems alright to me.

A:

Sounds like possibly your Selenium code is misusing quotes or something, so that the literal string Comments button is being understood as the XPath expression. 
Usually that error message shows the actual XPath expression after "The given selector", as in Selenium WebDriver throwing error while selecting the xpath.

The given selector
  //input[@type=checkbox]/following-sibling:://td[contains(text(),template]
  is either invalid or does not result in a WebElement.

