Sha256: 3090d1590ad7e65ca29b06a733521c05367b1648429510328e3a1c19b0061af5
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
module Watir class Element DOM_WAIT_JS = File.read("#{File.dirname(__FILE__)}/../extensions/js/waitForDom.js").freeze # # Returns true if DOM is changed within the element. # # @example Wait until DOM is changed inside element with default delay # browser.div(id: 'test').wait_until(&:dom_changed?).click # # @example Wait until DOM is changed inside element with default delay # browser.div(id: 'test').wait_until do |element| # element.dom_changed?(delay: 5) # end # # @param delay [Integer, Float] how long to wait for DOM modifications to start # def dom_changed?(delay: 1.1) element_call do begin script_timeout = driver.manage.timeouts.script_timeout driver.manage.timeouts.script_timeout = delay + Watir::DOM::Wait.minimum_script_timeout driver.execute_async_script(DOM_WAIT_JS, wd, delay) rescue Selenium::WebDriver::Error::JavascriptError => error # sometimes we start script execution before new page is loaded and # in rare cases ChromeDriver throws this error, we just swallow it and retry retry if error.message.include?('document unloaded while waiting for result') raise ensure driver.manage.timeouts.script_timeout = script_timeout end end end end # Element end # Watir
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
watir-dom-wait-0.4.0 | lib/watir/dom/elements/element.rb |