Module: Dekiru::Capybara::LegacyHelpers
- Defined in:
- lib/dekiru/capybara/legacy_helpers.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
6 7 8 |
# File 'lib/dekiru/capybara/legacy_helpers.rb', line 6 def self.included(base) Dekiru.deprecator.warn("#{self} is deprecated. If necessary, copy it to your project and use it.") end |
Instance Method Details
#finished_all_ajax_requests? ⇒ Boolean
39 40 41 |
# File 'lib/dekiru/capybara/legacy_helpers.rb', line 39 def finished_all_ajax_requests? page.evaluate_script('jQuery.active').zero? end |
#wait_for_ajax ⇒ Object
35 36 37 |
# File 'lib/dekiru/capybara/legacy_helpers.rb', line 35 def wait_for_ajax wait_until { finished_all_ajax_requests? } end |
#wait_for_event(event) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dekiru/capybara/legacy_helpers.rb', line 10 def wait_for_event(event) page.execute_script(" (function(){\n var eventName = '\#{event}';\n window._dekiruCapybaraWaitEvents = window._dekiruCapybaraWaitEvents || {};\n window._dekiruCapybaraWaitEvents[eventName] = 1;\n jQuery(document).one(eventName, function(){window._dekiruCapybaraWaitEvents[eventName] = 0;});\n })();\n EOS\n yield\n\n script = <<~\"EOS\"\n (function(){\n var eventName = '\#{event}';\n return window._dekiruCapybaraWaitEvents && window._dekiruCapybaraWaitEvents[eventName];\n })();\n EOS\n wait_until do\n result = page.evaluate_script(script)\n raise Error, 'wait_for_event: Missing context. probably moved to another page.' if result.nil?\n result == 0\n end\nend\n") |