1
0
Fork 0
mirror of https://github.com/teampoltergeist/poltergeist.git synced 2022-11-09 12:05:00 -05:00

clearing input before setting a new value by sending a backspace

Conflicts:
	README.md
This commit is contained in:
Daniel van Hoesel 2012-10-24 10:38:54 +02:00 committed by Jon Leighton
parent 2f0b0c0796
commit a43fe704aa
4 changed files with 19 additions and 2 deletions

View file

@ -286,6 +286,13 @@ Include as much information as possible. For example:
## Changes ##
### 1.0.2 ###
#### Bug fixes ####
* Clearing the value before setting a new value by sending a backspace.
This fixes the issue that you can't set an empty value. [Issue #184]
### 1.0.1 ###
#### Bug fixes ####

View file

@ -69,6 +69,7 @@ Poltergeist.Node = (function() {
Node.prototype.set = function(value) {
this.focusAndHighlight();
this.page.sendEvent('keypress', 16777219);
this.page.sendEvent('keypress', value.toString());
return this.blur();
};

View file

@ -54,5 +54,8 @@ class Poltergeist.Node
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()

View file

@ -120,11 +120,11 @@ describe Capybara::Session do
end
it 'fires the keydown event' do
@session.find(:css, '#changes_on_keydown').text.should == "6"
@session.find(:css, '#changes_on_keydown').text.should == "7"
end
it 'fires the keyup event' do
@session.find(:css, '#changes_on_keyup').text.should == "6"
@session.find(:css, '#changes_on_keyup').text.should == "7"
end
it 'fires the keypress event' do
@ -146,6 +146,12 @@ describe Capybara::Session do
it "fires the keyup event after the value is updated" do
@session.find(:css, '#value_on_keyup').text.should == "Hello!"
end
it "clears the input before setting the new value" do
element = @session.find(:css, '#change_me')
element.set ""
element.value.should == ""
end
end
it 'has no trouble clicking elements when the size of a document changes' do