lib/element.rb in gridium-1.1.42 vs lib/element.rb in gridium-1.1.43

- old
+ new

@@ -34,13 +34,13 @@ def element(opts = {}) timeout = opts[:timeout] || @timeout if stale? wait = Selenium::WebDriver::Wait.new :timeout => timeout, :interval => 1 if Gridium.config.visible_elements_only - wait.until { @element = displayed_element } + human_readable_error { wait.until { @element = displayed_element } } else - wait.until { @element = @parent.find_element(@by, @locator); Log.debug("[GRIDIUM::Element] Finding element #{self}..."); @element.enabled? } + human_readable_error { wait.until { @element = @parent.find_element(@by, @locator); Log.debug("[GRIDIUM::Element] Finding element #{self}..."); @element.enabled? } } end end @element end @@ -501,6 +501,11 @@ return false end true end + def human_readable_error(&block) + block.call + rescue StandardError => e + raise e.exception.class, "#{self} : #{e.message}" + end end