lib/watir/dom/elements/element.rb in watir-dom-wait-0.3.2 vs lib/watir/dom/elements/element.rb in watir-dom-wait-0.3.3

- old
+ new

@@ -15,21 +15,23 @@ # # @param delay [Integer, Float] how long to wait for DOM modifications to start # def dom_changed?(delay: 1.1) - driver.manage.timeouts.script_timeout = delay + 1 - driver.execute_async_script(DOM_WAIT_JS, wd, delay) - rescue Selenium::WebDriver::Error::StaleElementReferenceError - retry - 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 - # TODO: make sure we rollback to user-defined timeout - # blocked by https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/6608 - driver.manage.timeouts.script_timeout = 1 + element_call do + begin + driver.manage.timeouts.script_timeout = delay + 1 + 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 + # TODO: make sure we rollback to user-defined timeout + # blocked by https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/6608 + driver.manage.timeouts.script_timeout = 1 + end + end end end # Element end # Watir