Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus element when setting #280

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
- package-ecosystem: "bundler"
directory: "/"
rebase-strategy: "disabled"
insecure-external-code-execution: allow
schedule:
interval: "weekly"
open-pull-requests-limit: 99
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>
Loading