site_prism 2.11 → 2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +1 -1
- data/README.md +17 -4
- data/lib/site_prism/addressable_url_matcher.rb +2 -1
- data/lib/site_prism/element_container.rb +28 -13
- data/lib/site_prism/exceptions.rb +7 -1
- data/lib/site_prism/section.rb +11 -10
- data/lib/site_prism/version.rb +1 -1
- metadata +30 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 486bfe34bc7f4ab7dedc373ffdb850d146c731d8
|
4
|
+
data.tar.gz: 324a724708c627fbc2242bc783ac80a1626472e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62687b2613246d5f2a9afc1623d961ec43249439dbb9f7d391758c723832a587524cd617e4893bdf53405ac42aed942656892eb4269d7a1092d08245573e2796
|
7
|
+
data.tar.gz: c8065b3bb3cd831bb3ee12e975c701e9b29d998a45d8e640bca5b15c895fe4bfb18012c6fa24dba3ed40af9a53100424ffbc23c9ea212755a7a73bf195fcd60a
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Make sure to add your project/company to https://github.com/natritmeyer/site_pri
|
|
11
11
|
|
12
12
|
## Supported Rubies / Browsers
|
13
13
|
|
14
|
-
SitePrism is built and tested to work on Ruby 2.
|
14
|
+
SitePrism is built and tested to work on Ruby 2.1 - 2.4. There is also some limited support for the Ruby 1.9/2.0 series.
|
15
15
|
|
16
16
|
SitePrism should run on all major browsers. The gem's integration tests are ran on the latest version of Firefox.
|
17
17
|
|
@@ -1517,7 +1517,7 @@ end
|
|
1517
1517
|
To expose the iframe, reference it from another page or class using the `iframe`
|
1518
1518
|
method. The `iframe` method takes 3 arguments; the name by which you
|
1519
1519
|
would like to reference the iframe, the page class that represents the
|
1520
|
-
iframe, and
|
1520
|
+
iframe, and the CSS selector by which you can locate the iframe. For example:
|
1521
1521
|
|
1522
1522
|
```ruby
|
1523
1523
|
class PageContainingIframe < SitePrism::Page
|
@@ -1525,8 +1525,21 @@ class PageContainingIframe < SitePrism::Page
|
|
1525
1525
|
end
|
1526
1526
|
```
|
1527
1527
|
|
1528
|
-
|
1529
|
-
|
1528
|
+
### Locating an iframe
|
1529
|
+
|
1530
|
+
While the above example uses a CSS selector to find the iframe, it is also
|
1531
|
+
possible to use an XPath expression or the index of the iframe in its parent
|
1532
|
+
(a shortcut for an `nth-of-type` CSS selector). For example:
|
1533
|
+
|
1534
|
+
```ruby
|
1535
|
+
class PageContainingIframe < SitePrism::Page
|
1536
|
+
# XPath Expression:
|
1537
|
+
iframe :my_iframe, MyIframe, :xpath, '//iframe[@id="my_iframe_id"]'
|
1538
|
+
|
1539
|
+
# Index (nth-of-type) Selector:
|
1540
|
+
iframe :my_iframe, MyIframe, 0
|
1541
|
+
end
|
1542
|
+
```
|
1530
1543
|
|
1531
1544
|
### Testing for an iframe's existence
|
1532
1545
|
|
@@ -85,7 +85,8 @@ module SitePrism
|
|
85
85
|
component_url = uri.public_send(component).to_s
|
86
86
|
extracted_mappings = component_template.extract(component_url)
|
87
87
|
unless extracted_mappings
|
88
|
-
# to support Addressable's expansion of queries
|
88
|
+
# to support Addressable's expansion of queries
|
89
|
+
# ensure it's parsing the fragment as appropriate (e.g. {?params*})
|
89
90
|
prefix = COMPONENT_PREFIXES[component]
|
90
91
|
return nil unless prefix && (extracted_mappings = component_template.extract(prefix + component_url))
|
91
92
|
end
|
@@ -48,15 +48,15 @@ module SitePrism
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
def iframe(iframe_name, iframe_page_class,
|
52
|
-
|
53
|
-
|
51
|
+
def iframe(iframe_name, iframe_page_class, *args)
|
52
|
+
element_find_args = deduce_iframe_element_find_args(args)
|
53
|
+
scope_find_args = deduce_iframe_scope_find_args(args)
|
54
54
|
add_to_mapped_items iframe_name
|
55
|
-
create_existence_checker iframe_name,
|
56
|
-
create_nonexistence_checker iframe_name,
|
57
|
-
create_waiter iframe_name,
|
55
|
+
create_existence_checker iframe_name, *element_find_args
|
56
|
+
create_nonexistence_checker iframe_name, *element_find_args
|
57
|
+
create_waiter iframe_name, *element_find_args
|
58
58
|
define_method iframe_name do |&block|
|
59
|
-
within_frame
|
59
|
+
within_frame(*scope_find_args) do
|
60
60
|
block.call iframe_page_class.new
|
61
61
|
end
|
62
62
|
end
|
@@ -69,7 +69,8 @@ module SitePrism
|
|
69
69
|
|
70
70
|
def raise_if_block(obj, name, has_block)
|
71
71
|
return unless has_block
|
72
|
-
|
72
|
+
|
73
|
+
raise SitePrism::UnsupportedBlock, "#{obj.class}##{name}"
|
73
74
|
end
|
74
75
|
|
75
76
|
private
|
@@ -168,12 +169,26 @@ module SitePrism
|
|
168
169
|
end
|
169
170
|
end
|
170
171
|
|
171
|
-
def
|
172
|
-
|
172
|
+
def deduce_iframe_scope_find_args(args)
|
173
|
+
case args[0]
|
174
|
+
when Integer
|
175
|
+
[args[0]]
|
176
|
+
when String
|
177
|
+
[:css, args[0]]
|
178
|
+
else
|
179
|
+
args
|
180
|
+
end
|
173
181
|
end
|
174
182
|
|
175
|
-
def
|
176
|
-
|
183
|
+
def deduce_iframe_element_find_args(args)
|
184
|
+
case args[0]
|
185
|
+
when Integer
|
186
|
+
"iframe:nth-of-type(#{args[0] + 1})"
|
187
|
+
when String
|
188
|
+
[:css, args[0]]
|
189
|
+
else
|
190
|
+
args
|
191
|
+
end
|
177
192
|
end
|
178
193
|
|
179
194
|
def extract_section_options(args, &block)
|
@@ -184,7 +199,7 @@ module SitePrism
|
|
184
199
|
else
|
185
200
|
raise ArgumentError, 'You should provide section class either as a block, or as the second argument.'
|
186
201
|
end
|
187
|
-
|
202
|
+
[section_class, args]
|
188
203
|
end
|
189
204
|
end
|
190
205
|
end
|
@@ -14,6 +14,12 @@ module SitePrism
|
|
14
14
|
class TimeoutException < StandardError; end
|
15
15
|
class TimeOutWaitingForElementVisibility < StandardError; end
|
16
16
|
class TimeOutWaitingForElementInvisibility < StandardError; end
|
17
|
-
|
17
|
+
|
18
|
+
class UnsupportedBlock < StandardError
|
19
|
+
def message
|
20
|
+
"#{super} does not accept blocks, did you mean to define a (i)frame?"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
18
24
|
NotLoadedError = Class.new(StandardError)
|
19
25
|
end
|
data/lib/site_prism/section.rb
CHANGED
@@ -17,20 +17,21 @@ module SitePrism
|
|
17
17
|
Capybara.within(@root_element) { yield(self) } if block_given?
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
# Capybara::DSL module "delegates" Capybara methods to the "page" method
|
21
|
+
def page
|
22
|
+
root_element || Capybara.current_session
|
22
23
|
end
|
23
24
|
|
24
|
-
def
|
25
|
-
|
25
|
+
def visible?
|
26
|
+
page.visible?
|
26
27
|
end
|
27
28
|
|
28
29
|
def execute_script(input)
|
29
|
-
Capybara.current_session.execute_script
|
30
|
+
Capybara.current_session.execute_script(input)
|
30
31
|
end
|
31
32
|
|
32
33
|
def evaluate_script(input)
|
33
|
-
Capybara.current_session.evaluate_script
|
34
|
+
Capybara.current_session.evaluate_script(input)
|
34
35
|
end
|
35
36
|
|
36
37
|
def parent_page
|
@@ -41,16 +42,16 @@ module SitePrism
|
|
41
42
|
candidate_page
|
42
43
|
end
|
43
44
|
|
45
|
+
def native
|
46
|
+
root_element.native
|
47
|
+
end
|
48
|
+
|
44
49
|
private
|
45
50
|
|
46
51
|
def find_first(*find_args)
|
47
52
|
root_element.find(*find_args)
|
48
53
|
end
|
49
54
|
|
50
|
-
def find_all(*find_args)
|
51
|
-
root_element.all(*find_args)
|
52
|
-
end
|
53
|
-
|
54
55
|
def element_exists?(*find_args)
|
55
56
|
root_element.has_selector?(*find_args) unless root_element.nil?
|
56
57
|
end
|
data/lib/site_prism/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: site_prism
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
4
|
+
version: '2.12'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nat Ritmeyer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '2.
|
34
|
+
version: '2.12'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '2.
|
41
|
+
version: '2.12'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: cucumber
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,34 +67,20 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '11.0'
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: redcarpet
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - "~>"
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '3.0'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - "~>"
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '3.0'
|
84
70
|
- !ruby/object:Gem::Dependency
|
85
71
|
name: rspec
|
86
72
|
requirement: !ruby/object:Gem::Requirement
|
87
73
|
requirements:
|
88
74
|
- - "~>"
|
89
75
|
- !ruby/object:Gem::Version
|
90
|
-
version: '3.
|
76
|
+
version: '3.3'
|
91
77
|
type: :development
|
92
78
|
prerelease: false
|
93
79
|
version_requirements: !ruby/object:Gem::Requirement
|
94
80
|
requirements:
|
95
81
|
- - "~>"
|
96
82
|
- !ruby/object:Gem::Version
|
97
|
-
version: '3.
|
83
|
+
version: '3.3'
|
98
84
|
- !ruby/object:Gem::Dependency
|
99
85
|
name: rubocop
|
100
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,30 +99,50 @@ dependencies:
|
|
113
99
|
name: selenium-webdriver
|
114
100
|
requirement: !ruby/object:Gem::Requirement
|
115
101
|
requirements:
|
116
|
-
- - "
|
102
|
+
- - ">="
|
117
103
|
- !ruby/object:Gem::Version
|
118
104
|
version: 3.4.0
|
105
|
+
- - "<="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: 3.8.0
|
119
108
|
type: :development
|
120
109
|
prerelease: false
|
121
110
|
version_requirements: !ruby/object:Gem::Requirement
|
122
111
|
requirements:
|
123
|
-
- - "
|
112
|
+
- - ">="
|
124
113
|
- !ruby/object:Gem::Version
|
125
114
|
version: 3.4.0
|
115
|
+
- - "<="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 3.8.0
|
126
118
|
- !ruby/object:Gem::Dependency
|
127
119
|
name: simplecov
|
128
120
|
requirement: !ruby/object:Gem::Requirement
|
129
121
|
requirements:
|
130
122
|
- - ">="
|
131
123
|
- !ruby/object:Gem::Version
|
132
|
-
version: '0.
|
124
|
+
version: '0.12'
|
125
|
+
type: :development
|
126
|
+
prerelease: false
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.12'
|
132
|
+
- !ruby/object:Gem::Dependency
|
133
|
+
name: dotenv
|
134
|
+
requirement: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.1'
|
133
139
|
type: :development
|
134
140
|
prerelease: false
|
135
141
|
version_requirements: !ruby/object:Gem::Requirement
|
136
142
|
requirements:
|
137
143
|
- - ">="
|
138
144
|
- !ruby/object:Gem::Version
|
139
|
-
version: '
|
145
|
+
version: '2.1'
|
140
146
|
description: |-
|
141
147
|
SitePrism gives you a simple, clean and semantic DSL for describing your site.
|
142
148
|
SitePrism implements the Page Object Model pattern on top of Capybara.
|