edsl-pageobject 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44d3414e16ec1b3da3c9f0ca13363af44a345cbe3372640a4ed572e50b7337bb
4
- data.tar.gz: ef97de15b9cba8623ba435959f6d58fc30e5e632313dc91a46b9740f96147bff
3
+ metadata.gz: 98a7fde84b1d4f6260a0f5a2a527f448611f2bd1fe9b4c42e690015007ccca41
4
+ data.tar.gz: b5a6ab56fb8d2546e6069d57f7481e7e0dc3a593ef4b54a45ad92e337f6be9a9
5
5
  SHA512:
6
- metadata.gz: af4fde4408312d0d71321f186e026ac9f50c70b6caa3a994af48b35ecd3483b650f060a05bd25d6a5d46bbb089431edcd7ef71135b6eb06080002786959b00fd
7
- data.tar.gz: 6541f0649773eab4b9646b95f54d468c46cc40806fe3cbdfde6e6493f1fad4c4fe1474f9b665df93d4fadba76e1b2bc990f60f3c2103893df01974137d3475d4
6
+ metadata.gz: 0e833a978ec0d86e1008bffd70cec05b3405c9397bc756c712e4d1f6ac498569f6eb6dbdcff04620348c1594e8060a33bac057a17f428006a998131c7f9ebff6
7
+ data.tar.gz: 944524ffa17c0a442f630127b0fd2e401344dbb5e2b4fcc64b4bf90b90942726fcf26e74e74d967f068f68ed70c1199f78cef3a225b05b33b93d2b76b25a0710
@@ -89,7 +89,10 @@ module EDSL
89
89
  def wait_for_ajax(timeout = 30, message = nil)
90
90
  end_time = ::Time.now + timeout
91
91
  until ::Time.now > end_time
92
- return if browser.execute_script(::EDSL::PageObject::JavascriptFrameworkFacade.pending_requests) == 0
92
+ begin
93
+ return if browser.execute_script(::EDSL::PageObject::JavascriptFrameworkFacade.pending_requests) == 0
94
+ rescue Selenium::WebDriver::Error::UnknownError, Selenium::WebDriver::Error::JavascriptError
95
+ end
93
96
  sleep 0.5
94
97
  end
95
98
  message = "Timed out waiting for ajax requests to complete" unless message
@@ -53,6 +53,13 @@ module EDSL
53
53
  def _ready?
54
54
  true
55
55
  end
56
+
57
+ def leave_page_using(method, expected_url = nil)
58
+ cur_url = browser.url
59
+ method.call if method.is_a?(Proc)
60
+ send(method) unless method.is_a?(Proc)
61
+ Watir::Wait.until { expected_url ? browser.url == expected_url : browser.url != cur_url }
62
+ end
56
63
  end
57
64
  end
58
65
  end
@@ -2,10 +2,17 @@ require 'facets/string'
2
2
 
3
3
  module EDSL
4
4
  module PageObject
5
+
6
+ def self.fixture_cache
7
+ @@cache ||= {}
8
+ end
9
+
5
10
  # This module serves as a mixin for element container to support populating their
6
11
  # fields via a hash.
7
12
  module Population
8
13
 
14
+
15
+
9
16
  # This method allows you to specify a function to be used to fetch fixture data,
10
17
  # given a key. The value passed should either be a proc, or a method name for send.
11
18
  #
@@ -30,8 +37,10 @@ module EDSL
30
37
  # @param key [String, Symbol] What to fetch
31
38
  def fixture_fetch(key)
32
39
  ff = EDSL::PageObject::Population.fixture_fetcher
33
- return ff.call(key) if ff.is_a?(Proc)
34
- send(ff, key)
40
+ data = ff.call(key) if ff.is_a?(Proc)
41
+ data = send(ff, key) unless ff.is_a?(Proc)
42
+ EDSL::PageObject.fixture_cache[key] = data
43
+ data
35
44
  end
36
45
 
37
46
  # This method will populate the various elements within a container, using a hash.
@@ -55,7 +64,11 @@ module EDSL
55
64
  data = data.fetch(populate_key, data)
56
65
  data = data.fetch(populate_key.to_sym, data)
57
66
  data.each do |k, v|
58
- send("#{k}=", v) if respond_to?("#{k}=")
67
+ begin
68
+ send("#{k}=", v) if respond_to?("#{k}=")
69
+ rescue Exception => ex
70
+ raise "#{ex.message} raised with setting #{k}"
71
+ end
59
72
  end
60
73
  end
61
74
 
@@ -30,7 +30,7 @@ module EDSL
30
30
  EDSL.extend_dsl {
31
31
  def section(name, section_class, opts)
32
32
  element(name, { how: :div, assign_method: :populate_with,
33
- wrapper_fn: lambda { |element, _container| section_class.new(element, self) } }.merge(opts))
33
+ wrapper_fn: lambda { |element, container| section_class.new(element, container) } }.merge(opts))
34
34
  end
35
35
 
36
36
  alias_method :page_section, :section
@@ -1,5 +1,5 @@
1
1
  module EDSL
2
2
  module PageObject
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
@@ -1,3 +1,5 @@
1
+ require 'page_navigation'
2
+
1
3
  module EDSL
2
4
  module PageObject
3
5
  module Visitable
@@ -36,6 +38,7 @@ module EDSL
36
38
 
37
39
  # Most of this is a semi-direct copy from PageObject::PageFactory
38
40
  module Visitation
41
+ include PageNavigation
39
42
  #
40
43
  # Create and navigate to a page object. The navigation will only work if the
41
44
  # 'page_url' method was call on the page object.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edsl-pageobject
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donavan Stanley
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-17 00:00:00.000000000 Z
11
+ date: 2018-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler