lib/capybara/poltergeist/client/node.coffee in poltergeist-1.1.2 vs lib/capybara/poltergeist/client/node.coffee in poltergeist-1.2.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', 'setAttribute', 'isObsolete',
+ @DELEGATES = ['allText', 'visibleText', 'getAttribute', 'value', 'set', 'setAttribute', 'isObsolete',
'removeAttribute', 'isMultiple', 'select', 'tagName', 'find',
- 'isVisible', 'position', 'trigger', 'parentId', 'clickTest',
- 'scrollIntoView', 'isDOMEqual', 'focusAndHighlight', 'blur']
+ 'isVisible', 'position', 'trigger', 'parentId', 'mouseEventTest',
+ 'scrollIntoView', 'isDOMEqual', 'isDisabled']
constructor: (@page, @id) ->
parent: ->
new Poltergeist.Node(@page, this.parentId())
@@ -14,11 +14,11 @@
for name in @DELEGATES
do (name) =>
this.prototype[name] = (args...) ->
@page.nodeCall(@id, name, args)
- clickPosition: ->
+ mouseEventPosition: ->
viewport = @page.viewportSize()
pos = this.position()
middle = (start, end, size) ->
start + ((Math.min(end, size) - start) / 2)
@@ -26,36 +26,28 @@
{
x: middle(pos.left, pos.right, viewport.width),
y: middle(pos.top, pos.bottom, viewport.height)
}
- click: (event = 'click') ->
+ mouseEvent: (name) ->
this.scrollIntoView()
- pos = this.clickPosition()
- test = this.clickTest(pos.x, pos.y)
+ pos = this.mouseEventPosition()
+ test = this.mouseEventTest(pos.x, pos.y)
if test.status == 'success'
- @page.mouseEvent(event, pos.x, pos.y)
+ @page.mouseEvent(name, pos.x, pos.y)
pos
else
- throw new Poltergeist.ClickFailed(test.selector, pos)
+ throw new Poltergeist.MouseEventFailed(name, test.selector, pos)
dragTo: (other) ->
this.scrollIntoView()
- position = this.clickPosition()
- otherPosition = other.clickPosition()
+ position = this.mouseEventPosition()
+ otherPosition = other.mouseEventPosition()
@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()
- # Sending backspace to clear the input
- # keycode from: https://github.com/ariya/phantomjs/commit/cab2635e66d74b7e665c44400b8b20a8f225153a#L0R370
- @page.sendEvent('keypress', 16777219)
- @page.sendEvent('keypress', value.toString())
- this.blur()