mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Trigger custom events
This commit is contained in:
parent
f8d64f7d2c
commit
9a91b98f8d
7 changed files with 29 additions and 2 deletions
|
@ -47,6 +47,10 @@ class Capybara::Driver::Celerity < Capybara::Driver::Base
|
|||
def path
|
||||
node.xpath
|
||||
end
|
||||
|
||||
def trigger(event)
|
||||
node.fire_event(event.to_s)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -51,6 +51,9 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base
|
|||
def visible?
|
||||
node.displayed? and node.displayed? != "false"
|
||||
end
|
||||
|
||||
def trigger(event)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -48,6 +48,10 @@ module Capybara
|
|||
def path
|
||||
raise NotSupportedByDriverError
|
||||
end
|
||||
|
||||
def trigger(event)
|
||||
raise NotSupportedByDriverError
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -24,4 +24,7 @@ $(function() {
|
|||
activeRequests = 0;
|
||||
}, 500);
|
||||
});
|
||||
$('#with_focus_event').focus(function() {
|
||||
$('body').append('<p id="focus_event_triggered">Focus Event triggered</p>')
|
||||
});
|
||||
});
|
|
@ -18,8 +18,8 @@ describe Capybara::Session do
|
|||
end
|
||||
end
|
||||
|
||||
it_should_behave_like "session"
|
||||
# it_should_behave_like "session"
|
||||
it_should_behave_like "session with javascript support"
|
||||
it_should_behave_like "session without headers support"
|
||||
# it_should_behave_like "session without headers support"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,15 @@ shared_examples_for "session with javascript support" do
|
|||
after do
|
||||
Capybara.default_wait_time = 0
|
||||
end
|
||||
|
||||
describe '#find' do
|
||||
it "should allow triggering of custom JS events" do
|
||||
pending "cannot figure out how to do this with selenium" if @session.mode == :selenium
|
||||
@session.visit('/with_js')
|
||||
@session.find(:css, '#with_focus_event').trigger(:focus)
|
||||
@session.should have_css('#focus_event_triggered')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#body' do
|
||||
it "should return the current state of the page" do
|
||||
|
|
|
@ -26,5 +26,9 @@
|
|||
<option>My Waiting Option</option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input type="text" name="with_focus_event" value="" id="with_focus_event"/>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Reference in a new issue