Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
[rubycdp/ferrum#716]

### Fixed
- Number fields are typed with real key presses like text fields, so `clear:` and `rapid:` apply, their value was set
from JS with no key events
- `value` of a multiple select includes the selected options in an `<optgroup>`, it returned only the others
- `Node#send_keys` focuses an element without focus instead of clicking it, so a checkbox isn't toggled and a link isn't
followed, and the keys go to the end of a filled field instead of where the click put the caret
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/cuprite/javascripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
this.trigger(node, "focus");
this.setValue(node, "");

if (node.type == "number" || node.type == "date" || node.type == "range" || node.type == "time" || node.type == "month" || node.type == "week") {
if (node.type == "date" || node.type == "range" || node.type == "time" || node.type == "month" || node.type == "week") {
this.setValue(node, value);
this.input(node);
} else if (node.type == "datetime-local") {
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/cuprite/node/typing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Capybara
module Cuprite
class Node < Capybara::Driver::Node
module Typing
TYPED_INPUTS = %w[text password email search tel url].freeze
TYPED_INPUTS = %w[text password email search tel url number].freeze
SET_OPTIONS = %i[rapid clear].freeze
CLEAR_ERROR = "clear: takes nil, :none, :backspace or an Array of keys"
RAPID_SET_LENGTH = 30
Expand Down
7 changes: 7 additions & 0 deletions spec/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,13 @@
expect(element.value).to eq("-100")
end

it "appends to a number field with clear: :none" do
element = @session.find(:css, "#change_me_number")
element.set(12)
element.set(34, clear: :none)
expect(element.value).to eq("1234")
end

it "fires the keydown event" do
expect(@session.find(:css, "#changes_on_keydown").text).to eq("6")
end
Expand Down
Loading