lib/element.rb in gridium-1.1.10 vs lib/element.rb in gridium-1.1.11
- old
+ new
@@ -27,13 +27,15 @@
def to_s
"'#{@name}' (By:#{@by} => '#{@locator}')"
end
- def element
+ def element(opts = {})
+ timeout = opts[:timeout].nil? ? Gridium.config.element_timeout : opts[:timeout]
+
if stale?
- wait = Selenium::WebDriver::Wait.new :timeout => Gridium.config.element_timeout, :interval => 1
+ wait = Selenium::WebDriver::Wait.new :timeout => timeout, :interval => 1
if Gridium.config.visible_elements_only
wait.until { @element = displayed_element }
else
wait.until { @element = @parent.find_element(@by, @locator); Log.debug("[GRIDIUM::Element] Finding element #{self}..."); @element.enabled? }
end
@@ -74,20 +76,18 @@
# ================ #
# Element Commands #
# ================ #
# soft failure, will not kill test immediately
- def verify(timeout: nil)
+ def verify(timeout: Gridium.config.element_timeout)
Log.debug('[GRIDIUM::Element] Verifying new element...')
- timeout = Gridium.config.element_timeout if timeout.nil?
ElementVerification.new(self, timeout)
end
# hard failure, will kill test immediately
- def wait_until(timeout: nil)
+ def wait_until(timeout: Gridium.config.element_timeout)
Log.debug('[GRIDIUM::Element] Waiting for new element...')
- timeout = Gridium.config.element_timeout if timeout.nil?
ElementVerification.new(self, timeout, fail_test: true)
end
def attribute(name)
element.attribute(name)
@@ -95,12 +95,10 @@
def css_value(name)
element.css_value(name)
end
-
-
def present?
return element.enabled?
rescue StandardError => error
Log.debug("[GRIDIUM::Element] element.present? is false because this error was rescued: #{error}")
return false
@@ -256,10 +254,10 @@
$verification_passes += 1
ElementExtensions.jquery_click(self)
else
Log.error('[GRIDIUM::Element] Cannot jquery_click. Element is not present.')
end
- end
+ end
def size
element.size
end