lib/capybara/poltergeist/client/agent.coffee in poltergeist-1.4.1 vs lib/capybara/poltergeist/client/agent.coffee in poltergeist-1.5.0

- old
+ new

@@ -35,11 +35,12 @@ else results = within.querySelectorAll(selector) this.register(el) for el in results catch error - if error.code == DOMException.SYNTAX_ERR + # DOMException.INVALID_EXPRESSION_ERR is undefined, using pure code + if error.code == DOMException.SYNTAX_ERR || error.code == 51 throw new PoltergeistAgent.InvalidSelector else throw error register: (element) -> @@ -138,10 +139,16 @@ if @element.nodeName == "TEXTAREA" @element.textContent else @element.innerText + deleteText: -> + range = document.createRange() + range.selectNodeContents(@element) + window.getSelection().addRange(range) + window.getSelection().deleteFromDocument() + getAttribute: (name) -> if name == 'checked' || name == 'selected' @element[name] else @element.getAttribute(name) @@ -162,16 +169,19 @@ value = value.substr(0, @element.maxLength) @element.value = '' this.trigger('focus') - for char in value - keyCode = this.characterToKeyCode(char) - this.keyupdowned('keydown', keyCode) - @element.value += char + if @element.type == 'number' + @element.value = value + else + for char in value + keyCode = this.characterToKeyCode(char) + this.keyupdowned('keydown', keyCode) + @element.value += char - this.keypressed(false, false, false, false, char.charCodeAt(0), char.charCodeAt(0)) - this.keyupdowned('keyup', keyCode) + this.keypressed(false, false, false, false, char.charCodeAt(0), char.charCodeAt(0)) + this.keyupdowned('keyup', keyCode) this.changed() this.input() this.trigger('blur')