def xPathFirst(path):
  """Extends a XPath query to return the first result.

    >>> xPathFirst("//*[@class='test']")
    "(//*[@class='test'])[1]"

  @type  path: string
  @param path: the initial XPath
  @rtype: string
  @return: the XPath with first result selection
  """
  return "({0})[1]".format(path)