Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Simulate browsers events more closely
Browse files Browse the repository at this point in the history
  • Loading branch information
halogenandtoast committed Jan 27, 2012
1 parent 16c1637 commit 51c4dfe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions spec/driver_spec.rb
Expand Up @@ -637,12 +637,12 @@

it "triggers radio input events" do
subject.find("//input[@type='radio']").first.set(true)
subject.find("//li").map(&:text).should == %w(mousedown mouseup click change)
subject.find("//li").map(&:text).should == %w(mousedown mouseup change click)
end

it "triggers checkbox events" do
subject.find("//input[@type='checkbox']").first.set(true)
subject.find("//li").map(&:text).should == %w(mousedown mouseup click change)
subject.find("//li").map(&:text).should == %w(mousedown mouseup change click)
end
end

Expand Down
12 changes: 4 additions & 8 deletions src/capybara.js
Expand Up @@ -181,17 +181,13 @@ Capybara = {
this.trigger(index, "blur");

} else if (type === "checkbox" || type === "radio") {
node.checked = (value === "true");
this.trigger(index, "mousedown");
this.trigger(index, "mouseup");
this.trigger(index, "click");
this.trigger(index, "change");
if (node.checked != (value === "true")) {
this.click(index)
}

} else if (type === "file") {
this.lastAttachedFile = value;
this.trigger(index, "mousedown");
this.trigger(index, "mouseup");
this.trigger(index, "click");
this.click(index)

} else {
node.value = value;
Expand Down

0 comments on commit 51c4dfe

Please sign in to comment.