Skip to content

Commit 96493fb

Browse files
committed
Focus form control elements during fill_in
Closes rubycdp#157 Related to rubycdp#280 Change the `lib/capybara/cuprite/javascripts/index.js` to invoke [HTMLElement.focus][] directly, rather than triggering a synthetic `"focus"` event. [HTMLElement.focus]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
1 parent bc06cc0 commit 96493fb

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/capybara/cuprite/javascripts/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class Cuprite {
153153

154154
let valueBefore = node.value;
155155

156-
this.trigger(node, "focus");
156+
node.focus();
157157
this.setValue(node, "");
158158

159159
if (node.type == "number" || node.type == "date" || node.type == "range") {

spec/features/driver_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ def create_screenshot(file, *args)
15331533
it "fills a date" do
15341534
@session.fill_in "date_field", with: "2016-02-14"
15351535

1536-
expect(@session.find(:css, "#date_field").value).to eq("2016-02-14")
1536+
expect(@session.find(:css, "#date_field", focused: true).value).to eq("2016-02-14")
15371537
end
15381538
end
15391539

0 commit comments

Comments
 (0)