gless 1.4.2 → 1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/gless/config.rb +5 -0
- data/lib/gless/session.rb +9 -1
- data/lib/gless/wrap_watir.rb +19 -1
- data/lib/gless.rb +1 -1
- metadata +2 -2
data/lib/gless/config.rb
CHANGED
@@ -81,6 +81,11 @@ module Gless
|
|
81
81
|
@config.merge!(hash)
|
82
82
|
end
|
83
83
|
|
84
|
+
def deep_merge(b)
|
85
|
+
iter = -> a, step {a.merge(step) {|key, oldval, newval| [oldval, newval].all? {|v| v.kind_of? Hash} ? iter.(oldval, newval) : newval}};
|
86
|
+
@config = iter.(@config, b)
|
87
|
+
end
|
88
|
+
|
84
89
|
# Set an element in the configuration to the given value, passed after all
|
85
90
|
# of the indices.
|
86
91
|
#
|
data/lib/gless/session.rb
CHANGED
@@ -393,7 +393,12 @@ module Gless
|
|
393
393
|
# are for "timeout" seconds.
|
394
394
|
@timeout.times do
|
395
395
|
self.log.debug "Session: change_pages: yielding to passed block."
|
396
|
-
|
396
|
+
begin
|
397
|
+
yield if block_given?
|
398
|
+
rescue Watir::Exception::UnknownObjectException => e
|
399
|
+
error_message = "Caught UnknownObjectExepction; are the validators for #{@acceptable_pages} correct? #{e.inspect}"
|
400
|
+
log.warn "Session#change_pages: #{error_message}"
|
401
|
+
end
|
397
402
|
self.log.debug "Session: change_pages: done yielding to passed block."
|
398
403
|
|
399
404
|
if @acceptable_pages.member?( @current_page )
|
@@ -452,6 +457,9 @@ module Gless
|
|
452
457
|
log.info "Session: change_pages: We have successfully moved to page #{new_page.class.name}"
|
453
458
|
|
454
459
|
@previous_url = url
|
460
|
+
else
|
461
|
+
# Timed out.
|
462
|
+
error_message = "Session: change_pages: attempt to change pages to #{click_destination} timed out after #{@timeout} tries. If the clicked element exists, are the validators for #{@acceptable_pages} correct?"
|
455
463
|
end
|
456
464
|
|
457
465
|
return good_page, error_message
|
data/lib/gless/wrap_watir.rb
CHANGED
@@ -399,7 +399,12 @@ module Gless
|
|
399
399
|
# Unconditionally clicks once, without any error handling; if
|
400
400
|
# you want to try to execute a page transition no matter what,
|
401
401
|
# just use +click+
|
402
|
-
|
402
|
+
#
|
403
|
+
# @param [Boolean] change_pages (false) Call the session object's
|
404
|
+
# +change_pages+ method if the element targets a page with
|
405
|
+
# +click_destination+; otherwise, ignore page transitions. Defaults to
|
406
|
+
# +false+ simply for backwards-compatibility.
|
407
|
+
def click_once change_pages = false, &block
|
403
408
|
elem = find_elem
|
404
409
|
|
405
410
|
if @click_destination
|
@@ -409,8 +414,15 @@ module Gless
|
|
409
414
|
wrapper_logging('click', nil)
|
410
415
|
@session.log.debug "WrapWatir: Calling click on a #{elem.class.name} element identified by: #{trimmed_selectors.inspect}"
|
411
416
|
elem.click
|
417
|
+
|
418
|
+
if @click_destination && change_pages
|
419
|
+
@session.log.debug "WrapWatir: #{@name}.click_once: changing pages"
|
420
|
+
@session.change_pages @click_destination, &block
|
421
|
+
end
|
412
422
|
end
|
413
423
|
|
424
|
+
ClickTriesBeforeWarn = 3
|
425
|
+
|
414
426
|
# A wrapper around Watir's click; handles the changing of
|
415
427
|
# acceptable pages (i.e. click_destination processing, see
|
416
428
|
# {Gless::BasePage} and {Gless::Session} for more details).
|
@@ -426,10 +438,16 @@ module Gless
|
|
426
438
|
if @click_destination
|
427
439
|
@session.log.debug "WrapWatir: click: A #{elem.class.name} element identified by: #{trimmed_selectors.inspect} has a special destination when clicked, #{@click_destination}"
|
428
440
|
change_pages_out, change_pages_message = @session.change_pages( @click_destination ) do
|
441
|
+
tries = 0
|
429
442
|
wrapper_logging('click', nil)
|
430
443
|
@session.log.debug "WrapWatir: click: Calling click on a #{elem.class.name} element identified by: #{trimmed_selectors.inspect}"
|
431
444
|
if elem.exists?
|
432
445
|
wrap_watir_call :click
|
446
|
+
else
|
447
|
+
tries += 1
|
448
|
+
|
449
|
+
# Warn once.
|
450
|
+
@session.log.warn "WrapWatir#click: element #{@name} doesn't exist; waiting until present." if tries == ClickTriesBeforeWarn
|
433
451
|
end
|
434
452
|
if block_given?
|
435
453
|
yield
|
data/lib/gless.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.5'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-09-
|
13
|
+
date: 2013-09-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|