gless 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.txt +4 -0
- data/lib/gless/base_page.rb +12 -7
- data/lib/gless/session.rb +29 -37
- data/lib/gless/wrap_watir.rb +2 -1
- data/lib/gless.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4550c784a5681ac3c6c901717552c84bb73cf65
|
4
|
+
data.tar.gz: adf62a9f927189b9592e29dd0cdbcb6502b01eac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3dfdc73d9389a1ea10cda7e60dbb56bc7c0b67ba5a5c8b5a09153dd555cb9e942d684028209f0630fc45a082ccfca15e13be13471850443822ec21c29d7bbb7
|
7
|
+
data.tar.gz: 279b96b2666264d123100f0d9beccb2261f061afff0b4ecfe43a1a46141c75f5909832c974dede0489b75a7a50d87cf20d719d04e7c82bf24e46dbcef06cc1d5
|
data/Changelog.txt
CHANGED
@@ -25,3 +25,7 @@
|
|
25
25
|
of both extra browser capabilities and tags. The former is
|
26
26
|
now under :browser => :extras in the config file, and the
|
27
27
|
latter under :tag in the config file.
|
28
|
+
- 2.1.0: 22 May 2014: Added a "timeout" element to the config.
|
29
|
+
- 2.1.1: 31 Jul 2014: Major changes to what happenes when we fail to
|
30
|
+
arrive at a page; eventually the exception should trickle
|
31
|
+
up to the user.
|
data/lib/gless/base_page.rb
CHANGED
@@ -415,17 +415,17 @@ module Gless
|
|
415
415
|
@session.log.debug "In GenericBasePage, for #{self.class.name}, arrived?: validator element #{x} found."
|
416
416
|
else
|
417
417
|
# Probably never reached
|
418
|
-
@session.log.
|
418
|
+
@session.log.warn "In GenericBasePage, for #{self.class.name}, arrived?: validator element #{x} NOT found."
|
419
419
|
end
|
420
420
|
rescue Watir::Wait::TimeoutError => e
|
421
|
-
@session.log.
|
421
|
+
@session.log.warn "In GenericBasePage, for #{self.class.name}, arrived?: validator element #{x} NOT found."
|
422
422
|
all_validate = false
|
423
423
|
end
|
424
424
|
end
|
425
425
|
|
426
426
|
self.class.validator_blocks.each do |x|
|
427
427
|
if ! x.call @browser, @session
|
428
|
-
@session.log.
|
428
|
+
@session.log.warn "In GenericBasePage, for #{self.class.name}, arrived?: a validator block failed."
|
429
429
|
all_validate = false
|
430
430
|
end
|
431
431
|
end
|
@@ -435,13 +435,17 @@ module Gless
|
|
435
435
|
@session.log.debug "In GenericBasePage, for #{self.class.name}, arrived?: all validator elements found."
|
436
436
|
break
|
437
437
|
else
|
438
|
-
@session.log.
|
438
|
+
@session.log.warn "In GenericBasePage, for #{self.class.name}, arrived?: all validator elements found, but the current URL (#{@browser.url}) doesn't match the expected URL(s) (#{self.class.url_patterns}); trying again."
|
439
439
|
end
|
440
440
|
else
|
441
|
-
@session.log.
|
441
|
+
@session.log.warn "In GenericBasePage, for #{self.class.name}, arrived?: not all validator elements found, trying again."
|
442
442
|
end
|
443
443
|
end
|
444
444
|
|
445
|
+
if ! all_validate
|
446
|
+
@session.log.warn "In GenericBasePage, for #{self.class.name}, arrived?: not all validator elements found, continuing, but this it's unlikely to go well."
|
447
|
+
end
|
448
|
+
|
445
449
|
begin
|
446
450
|
if respond_to? :has_expected_title?
|
447
451
|
has_expected_title?.should be_true
|
@@ -457,7 +461,7 @@ module Gless
|
|
457
461
|
|
458
462
|
@session.log.debug "In GenericBasePage, for #{self.class.name}, arrived?: completed successfully."
|
459
463
|
return true
|
460
|
-
rescue
|
464
|
+
rescue StandardError => e
|
461
465
|
if @session.get_config :global, :debug
|
462
466
|
@session.log.debug "GenericBasePage, for #{self.class.name}, arrived?: something doesn't match (url or title or expected elements), exception information follows, then giving you a debugger"
|
463
467
|
@session.log.debug "Gless::BasePage: Had an exception in debug mode: #{e.inspect}"
|
@@ -465,7 +469,8 @@ module Gless
|
|
465
469
|
@session.log.debug "Gless::BasePage: Had an exception in debug mode: #{e.backtrace.join("\n")}"
|
466
470
|
debugger
|
467
471
|
else
|
468
|
-
|
472
|
+
@session.log.warn "In GenericBasePage, for #{self.class.name}, arrived?: failed to validate the page."
|
473
|
+
raise e
|
469
474
|
end
|
470
475
|
end
|
471
476
|
end
|
data/lib/gless/session.rb
CHANGED
@@ -64,7 +64,7 @@ module Gless
|
|
64
64
|
@browser = browser
|
65
65
|
@application = application
|
66
66
|
@pages = Hash.new
|
67
|
-
@timeout =
|
67
|
+
@timeout = config.get_default( 600, :global, :browser, :timeout )
|
68
68
|
@acceptable_pages = nil
|
69
69
|
@config = config
|
70
70
|
|
@@ -140,14 +140,6 @@ module Gless
|
|
140
140
|
|
141
141
|
good_page.should be_true, "Current URL is #{@browser.url}, which doesn't match any of the acceptable pages: #{@acceptable_pages}"
|
142
142
|
|
143
|
-
# While this is very thorough, it slows things down quite a
|
144
|
-
# bit, and should mostly be covered by
|
145
|
-
# Gless::WrapWatir#click ; leaving here in case we decide we
|
146
|
-
# need it later.
|
147
|
-
#
|
148
|
-
# log.debug "Session: checking for arrival at #{new_page.class.name}"
|
149
|
-
# new_page.arrived?.should be_true
|
150
|
-
|
151
143
|
url=@browser.url
|
152
144
|
log.debug "Session: refreshed browser URL: #{url}"
|
153
145
|
new_page.match_url(url).should be_true
|
@@ -386,22 +378,25 @@ module Gless
|
|
386
378
|
log.debug "Session: change_pages: checking to see if we have changed pages: #{@browser.title}, #{@current_page}, #{@acceptable_pages}"
|
387
379
|
|
388
380
|
good_page = false
|
389
|
-
error_message =
|
381
|
+
error_message = nil
|
390
382
|
new_page = nil
|
383
|
+
exceptions = {}
|
391
384
|
|
392
385
|
# See if we're on one of the acceptable pages; wait until we
|
393
386
|
# are for "timeout" seconds.
|
394
|
-
|
387
|
+
start_time = Time.now.to_i
|
388
|
+
while true
|
395
389
|
self.log.debug "Session: change_pages: yielding to passed block."
|
396
390
|
begin
|
397
391
|
yield if block_given?
|
398
392
|
rescue Watir::Exception::UnknownObjectException => e
|
399
|
-
error_message
|
400
|
-
log.warn "Session#change_pages: #{error_message}"
|
393
|
+
error_message ||= "Caught UnknownObjectExepction in the block we were passed; are the validators for #{@acceptable_pages} correct? Are you sure that's the right list of pages? Here's the exception: #{e.inspect}"
|
401
394
|
end
|
402
395
|
self.log.debug "Session: change_pages: done yielding to passed block."
|
403
396
|
|
404
|
-
|
397
|
+
# We're *definitely* staying on the same page; don't do any
|
398
|
+
# more work to check where we are
|
399
|
+
if @acceptable_pages.member?( @current_page ) and @acceptable_pages.length == 1
|
405
400
|
good_page = true
|
406
401
|
new_page = @current_page
|
407
402
|
break
|
@@ -421,27 +416,20 @@ module Gless
|
|
421
416
|
|
422
417
|
@acceptable_pages.each do |page|
|
423
418
|
log.debug "Session: change_pages: Checking our current url, #{url}, for a match in #{page.name}: #{@pages[page].match_url(url)}"
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
end
|
439
|
-
|
440
|
-
log.debug "Session: change_pages: checking for arrival at #{new_page.class.name}"
|
441
|
-
if not new_page.arrived?
|
442
|
-
good_page = false
|
443
|
-
error_message = "The current page, at #{url}, doesn't have all of the elements for any of the acceptable pages: #{@acceptable_pages}"
|
444
|
-
next
|
419
|
+
begin
|
420
|
+
if @pages[page].match_url(url) and @pages[page].arrived? == true
|
421
|
+
clear_cache
|
422
|
+
good_page = true
|
423
|
+
@current_page = page
|
424
|
+
new_page = @pages[page]
|
425
|
+
log.debug "Session: change_pages: we seem to be on #{page.name} at #{url}"
|
426
|
+
|
427
|
+
break
|
428
|
+
end
|
429
|
+
rescue StandardError => e
|
430
|
+
# Catching exceptions from "arrived?"; in this case we don't
|
431
|
+
# care until later
|
432
|
+
exceptions[page.name] = e.inspect
|
445
433
|
end
|
446
434
|
end
|
447
435
|
|
@@ -451,15 +439,19 @@ module Gless
|
|
451
439
|
sleep 1
|
452
440
|
end
|
453
441
|
end
|
442
|
+
|
443
|
+
if (Time.now.to_i - start_time) > @timeout
|
444
|
+
break
|
445
|
+
end
|
454
446
|
end
|
455
447
|
|
456
448
|
if good_page
|
457
|
-
log.info "Session: change_pages: We have successfully moved to page #{new_page.
|
449
|
+
log.info "Session: change_pages: We have successfully moved to page #{new_page.name}"
|
458
450
|
|
459
451
|
@previous_url = url
|
460
452
|
else
|
461
453
|
# Timed out.
|
462
|
-
error_message
|
454
|
+
error_message ||= "Session: change_pages: attempt to change pages to #{click_destination} timed out after #{@timeout} seconds, more or less. If the clicked element exists, are the validators for #{@acceptable_pages} correct? Here are the exceptions from each page we tried: #{YAML.dump(exceptions)}"
|
463
455
|
end
|
464
456
|
|
465
457
|
return good_page, error_message
|
data/lib/gless/wrap_watir.rb
CHANGED
@@ -415,7 +415,8 @@ module Gless
|
|
415
415
|
|
416
416
|
if @click_destination && change_pages
|
417
417
|
@session.log.debug "WrapWatir: #{@name}.click_once: changing pages"
|
418
|
-
@session.change_pages @click_destination, &block
|
418
|
+
change_pages_out, change_pages_message = @session.change_pages @click_destination, &block
|
419
|
+
change_pages_out.should be_true, change_pages_message
|
419
420
|
end
|
420
421
|
end
|
421
422
|
|
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: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Lee Powell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|