pagetience 0.3.2 → 0.4.0
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 +4 -4
- data/README.md +22 -1
- data/lib/pagetience/platforms/base.rb +4 -0
- data/lib/pagetience/platforms/page-object-gem.rb +4 -0
- data/lib/pagetience/version.rb +1 -1
- data/lib/pagetience.rb +30 -24
- 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: d72d9ede5f1719c7d819dac50cd9c96de24af39d
|
4
|
+
data.tar.gz: 1ffef24be2c258c445a33cf0fe346b44b8f19bd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6aa8a51684bf2443a6d9a5108226162f38faf5d442e84bdf1cade8685a1bfda2f20455ffd89b693ab037df9909285c83c19d82a640bc5dc0b7ae15804446dd35
|
7
|
+
data.tar.gz: 639efc4b0bb053daba6b563011862e9d993db2375d3f21426669d727e1d1d49cf6d5f97e359ea9fb75c6c32f36ea83f6482e34a03e046aae0a0a301ad5699e2b
|
data/README.md
CHANGED
@@ -36,7 +36,7 @@ end
|
|
36
36
|
When an instance of your page object is created then the required elements will be checked for.
|
37
37
|
|
38
38
|
#### Page transitions
|
39
|
-
Using the `
|
39
|
+
Using the `wait_for_transition_to` method within your page object, you can now wait for an expected page to transition to.
|
40
40
|
|
41
41
|
```ruby
|
42
42
|
class FirstPage
|
@@ -76,6 +76,27 @@ expect(@current_page.loaded?).to eq true # true
|
|
76
76
|
expect(@current_page).to be_an_instance_of SecondPage # true
|
77
77
|
```
|
78
78
|
|
79
|
+
#### Waiting for individual elements
|
80
|
+
The `wait_for_element` method allows you to wait for a specific element on the page to be there. It doesn't have to be one of your `required` fields -- it just has to declared.
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
class SomePage
|
84
|
+
include PageObject
|
85
|
+
include Pagetience
|
86
|
+
|
87
|
+
button :foo, id: 'foo'
|
88
|
+
|
89
|
+
def wait_for_foo
|
90
|
+
wait_for_element :foo
|
91
|
+
end
|
92
|
+
|
93
|
+
def wait_longer_for_foo
|
94
|
+
wait_for_element :foo, 60, 5
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
79
100
|
#### Adjusting the Timeout/Polling
|
80
101
|
You can use the `waiting` method to specify how long you want to wait and, optionally, at what interval to poll the page for element visibility.
|
81
102
|
|
data/lib/pagetience/version.rb
CHANGED
data/lib/pagetience.rb
CHANGED
@@ -31,7 +31,7 @@ module Pagetience
|
|
31
31
|
attr_reader :browser, :loaded
|
32
32
|
|
33
33
|
attr_reader :element_platform
|
34
|
-
attr_reader :
|
34
|
+
attr_reader :_required_elements
|
35
35
|
|
36
36
|
def self.included(base)
|
37
37
|
base.extend ClassMethods
|
@@ -51,8 +51,6 @@ module Pagetience
|
|
51
51
|
@_waiting_polling = _waiting_polling || 1
|
52
52
|
|
53
53
|
@_required_elements = _required_elements || []
|
54
|
-
@_underlying_elements = []
|
55
|
-
gather_underlying_elements
|
56
54
|
wait_for_required_elements
|
57
55
|
end
|
58
56
|
|
@@ -60,35 +58,43 @@ module Pagetience
|
|
60
58
|
!!@loaded
|
61
59
|
end
|
62
60
|
|
63
|
-
def
|
64
|
-
|
65
|
-
|
61
|
+
def wait_for_required_elements(timeout=nil, polling=nil)
|
62
|
+
opts = {
|
63
|
+
timeout: timeout || @_waiting_timeout,
|
64
|
+
polling: polling || @_waiting_polling,
|
65
|
+
expecting: true,
|
66
|
+
msg: "Timed out after polling every #{:polling}s for #{:timeout}s waiting for the page to be loaded."
|
67
|
+
}
|
68
|
+
wait_for(opts) do
|
69
|
+
@loaded = true unless @_required_elements.any? { |e| !@element_platform.is_element_present? e }
|
66
70
|
end
|
67
71
|
end
|
68
72
|
|
69
|
-
def
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
79
|
-
@_poller.until_enlightened true
|
80
|
-
|
81
|
-
unless loaded?
|
82
|
-
raise Pagetience::Exceptions::Timeout, "Timed out after polling every #{@_poller.polling}s for #{@_poller.timeout}s waiting for the page to be loaded."
|
83
|
-
end
|
73
|
+
def wait_for_element(sym, timeout=nil, polling=nil)
|
74
|
+
opts = {
|
75
|
+
timeout: timeout || @_waiting_timeout,
|
76
|
+
polling: polling || @_waiting_polling,
|
77
|
+
expecting: true,
|
78
|
+
msg: "Timed out after waiting for the element #{sym} to be present."
|
79
|
+
}
|
80
|
+
wait_for(opts) { @element_platform.is_element_present? sym }
|
84
81
|
end
|
85
82
|
|
86
|
-
def
|
83
|
+
def wait_for_transition_to(page, timeout=nil, polling=nil)
|
87
84
|
page = page.new browser
|
88
|
-
|
85
|
+
opts = {
|
86
|
+
timeout: timeout || @_waiting_timeout,
|
87
|
+
polling: polling || @_waiting_polling,
|
88
|
+
expecting: true,
|
89
|
+
msg: "Timed out after waiting for the page to transition to #{page}."
|
90
|
+
}
|
91
|
+
wait_for(opts) { page.loaded? }
|
89
92
|
page
|
90
93
|
end
|
91
|
-
|
94
|
+
|
95
|
+
def wait_for(opts={}, &block)
|
96
|
+
Pagetience::Meditate.for(opts) { block.call }
|
97
|
+
end
|
92
98
|
|
93
99
|
private
|
94
100
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagetience
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek McNeil
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|