watir_drops 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +3 -0
- data/CHANGES.md +4 -0
- data/lib/watir_drops/page_object.rb +54 -4
- data/watir_drops.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 280730b6901eb01a5744bc02c17e50c0d14fce76
|
4
|
+
data.tar.gz: deb0cd398b6c840f35346c37d110a70eff7de0f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5f878a47b275c0bd4c4865045cd30f7b0d32464105af3a11914f5c010d79b91211e5cc402f538e3d443c2068359249e03e0d1248ac4dc561b73f181a9a4e14a
|
7
|
+
data.tar.gz: d5e0bfd51542d40f8d6befc46e944a5ef762e5651d0f3134d2e3cc3d0e25ac8fe39ac6e0de09e55c3c17330c56fd7e032f80cc5bca76a0d712d8575f594f31f4
|
data/.rspec
ADDED
data/CHANGES.md
CHANGED
@@ -5,8 +5,13 @@ module WatirDrops
|
|
5
5
|
class << self
|
6
6
|
|
7
7
|
attr_writer :element_list
|
8
|
+
attr_writer :required_element_list
|
9
|
+
attr_reader :require_url
|
10
|
+
|
11
|
+
|
12
|
+
def page_url(required: false)
|
13
|
+
@require_url = required
|
8
14
|
|
9
|
-
def page_url
|
10
15
|
define_method("page_url") do |*args|
|
11
16
|
yield(*args)
|
12
17
|
end
|
@@ -16,12 +21,24 @@ module WatirDrops
|
|
16
21
|
end
|
17
22
|
end
|
18
23
|
|
24
|
+
|
25
|
+
def page_title
|
26
|
+
define_method("page_title") do |*args|
|
27
|
+
yield(*args)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
19
31
|
def element_list
|
20
32
|
@element_list ||= []
|
21
33
|
end
|
22
34
|
|
35
|
+
def required_element_list
|
36
|
+
@required_element_list ||= []
|
37
|
+
end
|
38
|
+
|
23
39
|
def inherited(subclass)
|
24
40
|
subclass.element_list = element_list.dup
|
41
|
+
subclass.required_element_list = required_element_list.dup
|
25
42
|
end
|
26
43
|
|
27
44
|
def elements(name, &block)
|
@@ -32,7 +49,7 @@ module WatirDrops
|
|
32
49
|
element_list << name.to_sym
|
33
50
|
end
|
34
51
|
|
35
|
-
def element(name, &block)
|
52
|
+
def element(name, required: false, &block)
|
36
53
|
define_method(name) do |*args|
|
37
54
|
self.instance_exec(*args, &block)
|
38
55
|
end
|
@@ -54,14 +71,20 @@ module WatirDrops
|
|
54
71
|
watir_element.click if val
|
55
72
|
end
|
56
73
|
end
|
57
|
-
|
58
74
|
element_list << name.to_sym
|
75
|
+
required_element_list << name.to_sym if required
|
59
76
|
end
|
60
77
|
|
61
78
|
def visit(*args)
|
62
|
-
new.tap
|
79
|
+
new.tap do |page|
|
80
|
+
page.goto(*args)
|
81
|
+
exception = Selenium::WebDriver::Error::WebDriverError
|
82
|
+
message = "Expected to be on #{page.class}, but conditions not met"
|
83
|
+
raise exception, message if page.page_verifiable? && !page.on_page?
|
84
|
+
end
|
63
85
|
end
|
64
86
|
|
87
|
+
|
65
88
|
def browser=(browser_input)
|
66
89
|
@@browser = browser_input
|
67
90
|
end
|
@@ -95,8 +118,32 @@ module WatirDrops
|
|
95
118
|
def inspect
|
96
119
|
'#<%s url=%s title=%s>' % [self.class, url.inspect, title.inspect]
|
97
120
|
end
|
121
|
+
|
98
122
|
alias selector_string inspect
|
99
123
|
|
124
|
+
|
125
|
+
def on_page?
|
126
|
+
exception = Selenium::WebDriver::Error::WebDriverError
|
127
|
+
message = "Can not verify page without any requirements set"
|
128
|
+
raise exception, message unless page_verifiable?
|
129
|
+
|
130
|
+
@browser.wait_until do |browser|
|
131
|
+
!self.class.require_url || page_url.gsub("#{URI.parse(page_url).scheme}://", '') == browser.url.gsub("#{URI.parse(browser.url).scheme}://", '')
|
132
|
+
end
|
133
|
+
|
134
|
+
@browser.wait_until do |browser|
|
135
|
+
!self.respond_to?(:page_title) || browser.title == page_title
|
136
|
+
end
|
137
|
+
|
138
|
+
@browser.wait_until do |_browser|
|
139
|
+
!self.class.required_element_list.any? || self.class.required_element_list.all? { |e| send(e).present? }
|
140
|
+
end
|
141
|
+
|
142
|
+
true
|
143
|
+
rescue Watir::Wait::TimeoutError
|
144
|
+
false
|
145
|
+
end
|
146
|
+
|
100
147
|
def method_missing(method, *args, &block)
|
101
148
|
if @browser.respond_to?(method)
|
102
149
|
@browser.send(method, *args, &block)
|
@@ -109,5 +156,8 @@ module WatirDrops
|
|
109
156
|
@browser.respond_to?(method) || super
|
110
157
|
end
|
111
158
|
|
159
|
+
def page_verifiable?
|
160
|
+
self.class.require_url || self.respond_to?(:page_title) || self.class.required_element_list.any?
|
161
|
+
end
|
112
162
|
end
|
113
163
|
end
|
data/watir_drops.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir_drops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Titus Fortner
|
@@ -118,6 +118,7 @@ extensions: []
|
|
118
118
|
extra_rdoc_files: []
|
119
119
|
files:
|
120
120
|
- ".gitignore"
|
121
|
+
- ".rspec"
|
121
122
|
- ".travis.yml"
|
122
123
|
- CHANGES.md
|
123
124
|
- Gemfile
|
@@ -148,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
149
|
version: '0'
|
149
150
|
requirements: []
|
150
151
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.
|
152
|
+
rubygems_version: 2.6.8
|
152
153
|
signing_key:
|
153
154
|
specification_version: 4
|
154
155
|
summary: Page Object Framework for use with Watir
|