gless 2.1.0 → 2.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5e8c9d821fa58dbac813938eb4bc0f48df3ac05
4
- data.tar.gz: 2a0ed6670fa38288d3fd68c6d80a69771605cab4
3
+ metadata.gz: e4550c784a5681ac3c6c901717552c84bb73cf65
4
+ data.tar.gz: adf62a9f927189b9592e29dd0cdbcb6502b01eac
5
5
  SHA512:
6
- metadata.gz: b0877a55cd0235541a072eb379eecd4a634bb429aab2f433dafd956ab2cd19fc0a5b3d3eee001859144163911425f6ff652c9a2d94fad10a0a3abea639b59fbf
7
- data.tar.gz: e41f940f2f3c1840f8850f29ea1c8df39d50ad61dfbe7ad0713a1f2c0b1d289ad297474288f1f89cf4a7c2f49d57e9ad4d2e2639889fbfaf08b7c13e9611f884
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.
@@ -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.debug "In GenericBasePage, for #{self.class.name}, arrived?: validator element #{x} NOT found."
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.debug "In GenericBasePage, for #{self.class.name}, arrived?: validator element #{x} NOT found."
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.debug "In GenericBasePage, for #{self.class.name}, arrived?: a validator block failed."
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.debug "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})"
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.debug "In GenericBasePage, for #{self.class.name}, arrived?: not all validator elements found, trying again."
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 Exception => e
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
- return false
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 = 30
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
- @timeout.times do
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 = "Caught UnknownObjectExepction; are the validators for #{@acceptable_pages} correct? #{e.inspect}"
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
- if @acceptable_pages.member?( @current_page )
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
- if @pages[page].match_url(url) and @pages[page].arrived? == true
425
- clear_cache
426
- good_page = true
427
- @current_page = page
428
- new_page = @pages[page]
429
- log.debug "Session: change_pages: we seem to be on #{page.name} at #{url}"
430
- end
431
- end
432
-
433
- if new_page
434
- if not new_page.match_url(url)
435
- good_page = false
436
- error_message = "Current URL is #{url}, which doesn't match that expected for any of the acceptable pages: #{@acceptable_pages}"
437
- next
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.class.name}"
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 = "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?"
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
@@ -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
@@ -6,7 +6,7 @@
6
6
  # project.
7
7
  module Gless
8
8
  # The current version number.
9
- VERSION = '2.1.0'
9
+ VERSION = '2.1.1'
10
10
 
11
11
  # Sets up the config, logger and browser instances, the ordering
12
12
  # of which is slightly tricky. If a block is given, the config, after being
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.0
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-05-22 00:00:00.000000000 Z
12
+ date: 2014-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec