lib/element.rb in gridium-1.1.22 vs lib/element.rb in gridium-1.1.23
- old
+ new
@@ -8,10 +8,11 @@
def initialize(name, by, locator, opts = {})
@name = name
@by = by
@locator = locator
+ @timeout = opts[:timeout] || Gridium.config.element_timeout
@element_screenshot = nil #used to store the path of element screenshots for comparison
# wrapped driver
@driver = Driver.driver
@@ -21,21 +22,18 @@
# should always be driver unless getting an element's child
@parent ||= (opts[:parent] || @driver)
#how long to wait between clearing an input and sending keys to it
@text_padding_time = 0.15
-
- @default_timeout = Gridium.config.element_timeout
end
def to_s
"'#{@name}' (By:#{@by} => '#{@locator}')"
end
def element(opts = {})
- timeout = opts[:timeout].nil? ? @default_timeout : opts[:timeout]
-
+ 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 }
else
@@ -78,16 +76,16 @@
# ================ #
# Element Commands #
# ================ #
# soft failure, will not kill test immediately
- def verify(timeout: Gridium.config.element_timeout)
+ def verify(timeout: @timeout)
Log.debug('[GRIDIUM::Element] Verifying new element...')
ElementVerification.new(self, timeout)
end
# hard failure, will kill test immediately
- def wait_until(timeout: Gridium.config.element_timeout)
+ def wait_until(timeout: @timeout)
Log.debug('[GRIDIUM::Element] Waiting for new element...')
ElementVerification.new(self, timeout, fail_test: true)
end
def attribute(name)