Use #click instead of #toggle for Selenium, Closes #50

This commit is contained in:
Jonas Nicklas 2010-02-27 19:27:06 +01:00
parent b8154a2f32
commit d298f4dc8c
4 changed files with 18 additions and 2 deletions

View File

@ -31,7 +31,7 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base
elsif tag_name == 'input' and type == 'radio'
node.select
elsif tag_name == 'input' and type == 'checkbox'
node.toggle
node.click
end
end

View File

@ -27,4 +27,7 @@ $(function() {
$('#with_focus_event').focus(function() {
$('body').append('<p id="focus_event_triggered">Focus Event triggered</p>')
});
});
$('#checkbox_with_event').click(function() {
$('body').append('<p id="checkbox_event_triggered">Checkbox event triggered</p>')
});
});

View File

@ -132,6 +132,14 @@ shared_examples_for "session with javascript support" do
end
end
describe '#check' do
it "should trigger associated events" do
@session.visit('/with_js')
@session.check('checkbox_with_event')
@session.should have_css('#checkbox_event_triggered');
end
end
describe '#has_xpath?' do
it "should wait for content to appear" do
@session.visit('/with_js')

View File

@ -30,5 +30,10 @@
<p>
<input type="text" name="with_focus_event" value="" id="with_focus_event"/>
</p>
<p>
<input type="checkbox" id="checkbox_with_event"/>
</p>
</body>
</html>