lib/capybara/poltergeist/client/node.coffee in poltergeist-0.7.0 vs lib/capybara/poltergeist/client/node.coffee in poltergeist-1.0.0
- old
+ new
@@ -1,12 +1,12 @@
# Proxy object for forwarding method calls to the node object inside the page.
class Poltergeist.Node
- @DELEGATES = ['text', 'getAttribute', 'value', 'set', 'setAttribute', 'isObsolete',
+ @DELEGATES = ['text', 'getAttribute', 'value', 'setAttribute', 'isObsolete',
'removeAttribute', 'isMultiple', 'select', 'tagName', 'find',
'isVisible', 'position', 'trigger', 'parentId', 'clickTest',
- 'scrollIntoView', 'isDOMEqual']
+ 'scrollIntoView', 'isDOMEqual', 'focusAndHighlight', 'blur']
constructor: (@page, @id) ->
parent: ->
new Poltergeist.Node(@page, this.parentId())
@@ -33,21 +33,26 @@
pos = this.clickPosition()
test = this.clickTest(pos.x, pos.y)
if test.status == 'success'
- @page.sendEvent('click', pos.x, pos.y)
+ @page.mouseEvent('click', pos.x, pos.y)
+ pos
else
throw new Poltergeist.ClickFailed(test.selector, pos)
dragTo: (other) ->
this.scrollIntoView()
position = this.clickPosition()
otherPosition = other.clickPosition()
- @page.sendEvent('mousedown', position.x, position.y)
- @page.sendEvent('mousemove', otherPosition.x, otherPosition.y)
- @page.sendEvent('mouseup', otherPosition.x, otherPosition.y)
+ @page.mouseEvent('mousedown', position.x, position.y)
+ @page.mouseEvent('mouseup', otherPosition.x, otherPosition.y)
isEqual: (other) ->
@page == other.page && this.isDOMEqual(other.id)
+
+ set: (value) ->
+ this.focusAndHighlight()
+ @page.sendEvent('keypress', value.toString())
+ this.blur()