Module: Capybara::Lockstep
- Extended by:
- Configuration, Logging, PageAccess
- Defined in:
- lib/capybara-lockstep.rb,
lib/capybara-lockstep/util.rb,
lib/capybara-lockstep/client.rb,
lib/capybara-lockstep/errors.rb,
lib/capybara-lockstep/helper.rb,
lib/capybara-lockstep/server.rb,
lib/capybara-lockstep/logging.rb,
lib/capybara-lockstep/version.rb,
lib/capybara-lockstep/lockstep.rb,
lib/capybara-lockstep/middleware.rb,
lib/capybara-lockstep/page_access.rb,
lib/capybara-lockstep/capybara_ext.rb,
lib/capybara-lockstep/capybara_ext.rb,
lib/capybara-lockstep/capybara_ext.rb,
lib/capybara-lockstep/capybara_ext.rb,
lib/capybara-lockstep/configuration.rb
Defined Under Namespace
Modules: Configuration, Helper, Logging, PageAccess, SynchronizeAroundScriptMethod, SynchronizeMacros, SynchronizeWithCatchUp, Util, VisitWithWaiting Classes: Client, Error, Middleware, Server, Timeout
Constant Summary collapse
- VERSION =
"2.2.2"
Class Attribute Summary collapse
-
.synchronizing ⇒ Object
(also: synchronizing?)
Returns the value of attribute synchronizing.
Class Method Summary collapse
-
.auto_synchronize(**options) ⇒ Object
Automatic synchronization from within the capybara-lockstep should always call #auto_synchronize.
- .client ⇒ Object
- .server ⇒ Object
- .synchronize(lazy: false, log: 'Synchronizing') ⇒ Object
- .unsynchronize ⇒ Object
Methods included from PageAccess
alert_present?, javascript_driver?, page
Methods included from Logging
Methods included from Configuration
after_synchronize, debug, debug=, debug?, enabled=, mode, mode=, timeout, timeout=, timeout_with, timeout_with=, wait_tasks, wait_tasks=, with_mode
Class Attribute Details
.synchronizing ⇒ Object Also known as: synchronizing?
Returns the value of attribute synchronizing.
8 9 10 |
# File 'lib/capybara-lockstep/lockstep.rb', line 8 def synchronizing @synchronizing end |
Class Method Details
.auto_synchronize(**options) ⇒ Object
Automatic synchronization from within the capybara-lockstep should always call #auto_synchronize. This only synchronizes IFF in :auto mode, i.e. the user has not explicitly disabled automatic syncing. The :auto mode has nothing to do with the { lazy } option.
18 19 20 21 22 |
# File 'lib/capybara-lockstep/lockstep.rb', line 18 def auto_synchronize(**) if mode == :auto synchronize(**) end end |
.client ⇒ Object
71 72 73 |
# File 'lib/capybara-lockstep/lockstep.rb', line 71 def client @client ||= Client.new end |
.server ⇒ Object
67 68 69 |
# File 'lib/capybara-lockstep/lockstep.rb', line 67 def server @server ||= Server.new end |
.synchronize(lazy: false, log: 'Synchronizing') ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/capybara-lockstep/lockstep.rb', line 24 def synchronize(lazy: false, log: 'Synchronizing') if synchronizing? || mode == :off return end # The { lazy } option is a performance optimization that will prevent capybara-lockstep # from synchronizing multiple times in expressions like `page.find('.foo').find('.bar')`. # The { lazy } option has nothing todo with :auto mode. # # With { lazy: true } we only synchronize when the Ruby-side thinks we're out of sync. # This saves us an expensive execute_script() roundtrip that goes to the browser and back. # However the knowledge of the Ruby-side is limited: We only assume that we're out of sync # after a page load or after a Capybara command. There may be additional client-side work # that the Ruby-side is not aware of, e.g. an AJAX call scheduled by a timeout. # # With { lazy: false } we force synchronization with the browser, whether the Ruby-side # thinks we're in sync or not. This always makes an execute_script() rountrip, but picks up # non-lazy synchronization so we pick up client-side work that have not been caused # by Capybara commands. will_synchronize_client = !(lazy && client.synchronized?) begin # Synchronizing the server is free, so we ignore { lazy } and do it every time. server.synchronize if will_synchronize_client self.log(log) self.synchronizing = true client.synchronize # Synchronizing the server is free, so we ignore { lazy } and do it every time. server.synchronize end ensure self.synchronizing = false end if will_synchronize_client run_after_synchronize_callbacks end end |
.unsynchronize ⇒ Object
11 12 13 |
# File 'lib/capybara-lockstep/lockstep.rb', line 11 def unsynchronize client.synchronized = false end |