Skip to content
Open
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
1 change: 1 addition & 0 deletions lib/capybara/cuprite/javascripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class Cuprite {

let valueBefore = node.value;

node.focus();
this.trigger(node, "focus");
this.setValue(node, "");

Expand Down
13 changes: 13 additions & 0 deletions spec/features/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,19 @@ def create_screenshot(file, *args)
end
end

context "input_fields" do
before { @session.visit("/cuprite/input_fields") }

it "focuses the element when filling in the value" do
input = @session.find(:css, "#text_field")
@session.fill_in "text_field", with: "2016-02-14"

expect(@session.find(:css, "#text_field").value).to eq("2016-02-14")
node = @session.driver.evaluate_script("document.activeElement")
expect(node).to eq input
end
end

context "evaluate_script" do
it "can return an element" do
@session.visit("/cuprite/send_keys")
Expand Down
9 changes: 9 additions & 0 deletions spec/support/views/input_fields.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
</head>

<body>
<input type="text" id="text_field" name="text_field"/>
</body>
</html>