Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

clearing input before setting a new value by sending a backspace

  • Loading branch information...
commit 6b9fc78ca93438ecacf62cad0772dd270712f4bd 1 parent 0f258f2
@s0meone s0meone authored
View
5 README.md
@@ -298,6 +298,11 @@ Include as much information as possible. For example:
* Add `page.driver.click(x, y)` to click precise coordinates.
(Micah Geisel)
+#### 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
1  lib/capybara/poltergeist/client/compiled/node.js
@@ -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
3  lib/capybara/poltergeist/client/node.coffee
@@ -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
10 spec/integration/session_spec.rb
@@ -120,11 +120,11 @@
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 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.