 
     element.dispatchEvent(event)
 
-  #
-  # Determines whether the given node/xpath endpoint is visible.
-  #
-  # ==== Parameters
-  # xpathOrNode<HTMLElement, Xpath>:: The thing to check for visibility.
-  #
-  # ==== Notes
-  # Returns +true+ when given a text node.
-  #
-  # @public
-  #
+  # Public: Determines whether a node is visible.
+  #
+  # xpathOrNode - If it's a Node, uses it as the Node to check for visibility.
+  #               Otherwise it should be a String xpath.
+  #
+  # Examples
+  #
+  #   page.visible '//imnotonthispage'
+  #   # => false
+  #
+  #   page.visible '//div[contains(@style, "display:none")]'
+  #   # => false
+  #
+  #   page.visible '//body'
+  #   # => true
+  #
+  #   page.visible '//div[@class="this-class-hides-things"]//a'
+  #   # => false
+  #
+  # Returns a Boolean indicating whether the Node is visible.
+  # Raises DocumentMismatchError given a node not belonging to this page.
   visible: (xpathOrNode) ->
     element = privacy.untaint @find(xpathOrNode)
 

privacy   = require 'util/privacy'
{tryCatch, tryThrow} = require 'util/try'

# ==== Types (shortcuts for use in this file)
# Xpath:: <String, Array[String], Pathway, Pathset>
#
EVENT_TYPE_MAP =
  click:     'MouseEvents'
  mousedown: 'MouseEvents'


      return null

  # Public: Finds matching nodes on the page. This is much like find(), but returns
  # all matching nodes instead of a single node.
  #
  # xpathOrNode - If it's a Node, returns it wrapped in an Array.
  #               Otherwise it should be a String xpath.
  # scope - An Element to restrict the search to.
  #
  # Examples
  #
  #   # finds all links on the page
  #   page.select '//a'
  #
  #   # gets a string containing all the text strings in the <body>
  #   (page.select '//text()', page.body).join('')
  #
  # Returns an Array of tainted Nodes found by xpath.
  # Raises DocumentMismatchError given a node not belonging to this page.
  select: (xpathOrNode, scope) ->
    if xpathOrNode?.nodeType
      DocumentMismatchError.assert @, xpathOrNode
      return [xpathOrNode]

    xpath = Pathway.from(xpathOrNode)
    return xpath.select @document, scope and @find(scope)

  # Public: Finds the first matching node, throwing an error
  # if there is no such matching node. Use this when you want to blow up
  # when the node cannot be found.
  #
  # xpathOrNode - If it's a Node, just returns it. Otherwise it should
  #               be a String xpath.
  # scope - An Element to restrict the xpath search to, ignored if xpathOrNode
  #         is a Node.
  #
  # Examples
  #
  #   # raises NodeNotFoundError because the xpath condition can never be satisfied
  #   page.findStrict '//*[@id!=@id]'
  #
  #   # just like page.find() when there's at least one link on the page
  #   link = page.findStrict '//a'
  #
  # Returns a tainted Node.
  # Raises DocumentMismatchError given a node not belonging to this page.
  # Raises NodeNotFoundError given an xpath for which there are no matches.
  findStrict: (xpathOrNode, scope) ->
    if result = @find xpathOrNode, scope
      return result

    NodeNotFoundError.raise @, xpathOrNode

  # Public: Fills an element with a given value. Note that the value will
  # be truncated according to any maxlength property found on the Element.
  #
  # xpathOrNode - If it's an Element, uses it as the Element to fill.
  #               Otherwise it should be a String xpath.
  # valueOrXpathOrNode - If it's a String, the value to use when filling
  #                      the Element. Otherwise it should be an Element
  #                      whose value we use to fill the Element.
  #
  # Examples
  #
  #   # fill in the search field
  #   page.fill '//input[@name="q"]', "angry birds"
  #
  #   # select an option in a dropdown
  #   colorSelect = page.findStrict '//select[@name="color"]'
  #   page.fill colorSelect, colorSelect.options[1]
  #
  # Returns nothing.
  # Raises DocumentMismatchError given a node not belonging to this page.
  # Raises NodeNotFoundError given an xpath for which there are no matches.
  fill: (xpathOrNode, valueOrXpathOrNode) ->
    tryThrow 'Page.fill', (log) =>
      element = privacy.untaint @findStrict(xpathOrNode)
