Simulate browsers events more closely

This commit is contained in:
Matthew Mongeau 2012-01-27 18:03:38 -05:00
parent 16c16372c8
commit 51c4dfe141
2 changed files with 6 additions and 10 deletions

View File

@ -637,12 +637,12 @@ describe Capybara::Driver::Webkit do
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

View File

@ -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;