sapphire 0.5.9 → 0.6.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.
- data/lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb +209 -199
- data/lib/sapphire/Strategies/HashStrategy.rb +11 -7
- data/lib/sapphire/Testing/Coverage/{Test.rb → Behavior.rb} +3 -3
- data/lib/sapphire/Testing/Coverage/Feature.rb +3 -3
- data/lib/sapphire/Testing/Coverage/Requirement.rb +4 -4
- data/lib/sapphire/version.rb +1 -1
- metadata +9 -9
@@ -1,199 +1,209 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module WebAbstractions
|
3
|
-
module RubySeleniumWebDriver
|
4
|
-
|
5
|
-
attr_reader :rootUrl
|
6
|
-
|
7
|
-
def Init(url)
|
8
|
-
@rootUrl = url
|
9
|
-
end
|
10
|
-
|
11
|
-
def Close
|
12
|
-
self.browser.close
|
13
|
-
end
|
14
|
-
|
15
|
-
def Switch
|
16
|
-
self.browser.switch_to.window(self.browser.window_handles[0])
|
17
|
-
end
|
18
|
-
|
19
|
-
def Type(keys)
|
20
|
-
self.browser.action.send_keys(keys).perform()
|
21
|
-
end
|
22
|
-
|
23
|
-
def AcceptAlert
|
24
|
-
alert = self.browser.switch_to.alert
|
25
|
-
alert.accept()
|
26
|
-
self.browser.switch_to.window(self.browser.window_handles[0])
|
27
|
-
end
|
28
|
-
|
29
|
-
def SetAlert(text)
|
30
|
-
alert = self.browser.switch_to.alert
|
31
|
-
alert.send_keys(text)
|
32
|
-
alert.accept()
|
33
|
-
self.browser.switch_to.window(self.browser.window_handles[0])
|
34
|
-
end
|
35
|
-
|
36
|
-
def ClosePopup
|
37
|
-
self.browser.switch_to.window(self.browser.window_handles.last)
|
38
|
-
self.browser.close
|
39
|
-
self.browser.switch_to.window(self.browser.window_handles[0])
|
40
|
-
end
|
41
|
-
|
42
|
-
def SwitchToPopup
|
43
|
-
self.browser.switch_to.window(self.browser.window_handles.last)
|
44
|
-
end
|
45
|
-
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
url
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
def
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
x =
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
array.
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
end
|
191
|
-
|
192
|
-
def
|
193
|
-
|
194
|
-
end
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
1
|
+
module Sapphire
|
2
|
+
module WebAbstractions
|
3
|
+
module RubySeleniumWebDriver
|
4
|
+
|
5
|
+
attr_reader :rootUrl
|
6
|
+
|
7
|
+
def Init(url)
|
8
|
+
@rootUrl = url
|
9
|
+
end
|
10
|
+
|
11
|
+
def Close
|
12
|
+
self.browser.close
|
13
|
+
end
|
14
|
+
|
15
|
+
def Switch
|
16
|
+
self.browser.switch_to.window(self.browser.window_handles[0])
|
17
|
+
end
|
18
|
+
|
19
|
+
def Type(keys)
|
20
|
+
self.browser.action.send_keys(keys).perform()
|
21
|
+
end
|
22
|
+
|
23
|
+
def AcceptAlert
|
24
|
+
alert = self.browser.switch_to.alert
|
25
|
+
alert.accept()
|
26
|
+
self.browser.switch_to.window(self.browser.window_handles[0])
|
27
|
+
end
|
28
|
+
|
29
|
+
def SetAlert(text)
|
30
|
+
alert = self.browser.switch_to.alert
|
31
|
+
alert.send_keys(text)
|
32
|
+
alert.accept()
|
33
|
+
self.browser.switch_to.window(self.browser.window_handles[0])
|
34
|
+
end
|
35
|
+
|
36
|
+
def ClosePopup
|
37
|
+
self.browser.switch_to.window(self.browser.window_handles.last)
|
38
|
+
self.browser.close
|
39
|
+
self.browser.switch_to.window(self.browser.window_handles[0])
|
40
|
+
end
|
41
|
+
|
42
|
+
def SwitchToPopup
|
43
|
+
self.browser.switch_to.window(self.browser.window_handles.last)
|
44
|
+
end
|
45
|
+
|
46
|
+
def SwitchToIFrame(frame)
|
47
|
+
self.browser.switch_to.frame(frame)
|
48
|
+
end
|
49
|
+
|
50
|
+
def SetRootUrl(url)
|
51
|
+
if(url.instance_of?(String))
|
52
|
+
self.Init(url)
|
53
|
+
else
|
54
|
+
x = url.new().Url
|
55
|
+
self.Init(x)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def NavigateTo(page)
|
60
|
+
if(page.is_a? Class)
|
61
|
+
nav = page.new
|
62
|
+
else
|
63
|
+
nav = page
|
64
|
+
end
|
65
|
+
|
66
|
+
self.browser.get "https://" + nav.Url
|
67
|
+
nav.Init
|
68
|
+
nav
|
69
|
+
end
|
70
|
+
|
71
|
+
def CurrentUrl
|
72
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 30)
|
73
|
+
url = wait.until { x = self.browser.current_url
|
74
|
+
x unless x == nil
|
75
|
+
}
|
76
|
+
|
77
|
+
url
|
78
|
+
end
|
79
|
+
|
80
|
+
def Reload
|
81
|
+
self.browser.get self.CurrentUrl
|
82
|
+
end
|
83
|
+
|
84
|
+
def ShouldNavigateTo(page)
|
85
|
+
if(page.is_a? Class)
|
86
|
+
nav = page.new
|
87
|
+
else
|
88
|
+
nav = page
|
89
|
+
end
|
90
|
+
|
91
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 30)
|
92
|
+
begin
|
93
|
+
found = wait.until {
|
94
|
+
x = self.CurrentUrl.upcase.start_with?("HTTP://" + nav.Url.upcase) || self.CurrentUrl.upcase.start_with?("HTTPS://" + nav.Url.upcase)
|
95
|
+
if(x == false)
|
96
|
+
nav.AlternateUrls.each do |url|
|
97
|
+
if( x == false)
|
98
|
+
x = self.CurrentUrl.upcase.start_with?("HTTP://" + url.upcase) || self.CurrentUrl.upcase.start_with?("HTTPS://" + url.upcase)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
x
|
103
|
+
}
|
104
|
+
rescue
|
105
|
+
temp = Evaluation.new(self.CurrentUrl, nav.Url)
|
106
|
+
return temp, nav
|
107
|
+
end
|
108
|
+
|
109
|
+
temp = Evaluation.new(found, true)
|
110
|
+
return temp, nav
|
111
|
+
end
|
112
|
+
|
113
|
+
def Run(background)
|
114
|
+
scenario = background.new
|
115
|
+
scenario.Run
|
116
|
+
end
|
117
|
+
|
118
|
+
def ShouldShow(page)
|
119
|
+
self.ShouldNavigateTo page
|
120
|
+
end
|
121
|
+
|
122
|
+
def ShouldTransitionTo(url)
|
123
|
+
if(url.instance_of?(String))
|
124
|
+
temp = Evaluation.new(self.CurrentUrl.upcase.start_with?("HTTP://" + url.upcase) || self.CurrentUrl.upcase.start_with?("HTTPS://" + url.upcase), true)
|
125
|
+
@rootUrl = url
|
126
|
+
else
|
127
|
+
x = url.new().Url
|
128
|
+
temp = Evaluation.new(self.CurrentUrl.upcase.start_with?("HTTP://" + x.upcase) || self.CurrentUrl.upcase.start_with?("HTTPS://" + x.upcase), true)
|
129
|
+
@rootUrl = x
|
130
|
+
end
|
131
|
+
|
132
|
+
return temp
|
133
|
+
end
|
134
|
+
|
135
|
+
def FindItem(array)
|
136
|
+
masterWait = Selenium::WebDriver::Wait.new(:timeout => 30)
|
137
|
+
|
138
|
+
element = masterWait.until {
|
139
|
+
x = nil
|
140
|
+
array.each do |item|
|
141
|
+
|
142
|
+
if item.is_a? Hash
|
143
|
+
begin
|
144
|
+
x = self.FindElement item.keys.first, item.fetch(item.keys.first)
|
145
|
+
rescue
|
146
|
+
#do nothing, let it keep looping
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
x = self.FindElement item[0], item[1] if item.is_a? Array
|
151
|
+
|
152
|
+
return x if x != nil
|
153
|
+
|
154
|
+
end if array.is_a? Array
|
155
|
+
|
156
|
+
x = self.FindElement array.keys.first, array.fetch(array.keys.first) if array.is_a? Hash
|
157
|
+
return x if x != nil
|
158
|
+
}
|
159
|
+
return element if element != nil
|
160
|
+
raise "Could not find control for array: " + array.to_s
|
161
|
+
end
|
162
|
+
|
163
|
+
def FindAllItems(array)
|
164
|
+
masterWait = Selenium::WebDriver::Wait.new(:timeout => 30)
|
165
|
+
|
166
|
+
element = masterWait.until {
|
167
|
+
x = nil
|
168
|
+
array.each do |item|
|
169
|
+
|
170
|
+
if item.is_a? Hash
|
171
|
+
begin
|
172
|
+
x = self.FindElements item.keys.first, item.fetch(item.keys.first)
|
173
|
+
x = nil if x.is_a? Array and x.empty?
|
174
|
+
rescue
|
175
|
+
#do nothing, let it keep looping
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
x = self.FindElements item[0], item[1] if item.is_a? Array
|
180
|
+
x = nil if x.is_a? Array and x.empty?
|
181
|
+
return x if x != nil
|
182
|
+
|
183
|
+
end if array.is_a? Array
|
184
|
+
|
185
|
+
x = self.FindElement array.keys.first, array.fetch(array.keys.first) if array.is_a? Hash
|
186
|
+
return x if x != nil
|
187
|
+
}
|
188
|
+
return element if element != nil
|
189
|
+
raise "Could not find control for array: " + array.to_s
|
190
|
+
end
|
191
|
+
|
192
|
+
def FindElement(discriminator, selector)
|
193
|
+
self.browser.find_element discriminator, selector
|
194
|
+
end
|
195
|
+
|
196
|
+
def FindElements(discriminator, selector)
|
197
|
+
self.browser.find_elements discriminator, selector
|
198
|
+
end
|
199
|
+
|
200
|
+
def ExecuteScript(script)
|
201
|
+
self.browser.execute_script(script)
|
202
|
+
end
|
203
|
+
|
204
|
+
def Create(type)
|
205
|
+
Selenium::WebDriver.for type
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
@@ -5,14 +5,18 @@ module Sapphire
|
|
5
5
|
def Show(item, modifier)
|
6
6
|
ExecuteHashAgainstControl(item, @page) do |control, arg|
|
7
7
|
wait = Selenium::WebDriver::Wait.new(:timeout => 30)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
begin
|
9
|
+
evaluation = wait.until { x = control
|
10
|
+
val = x.Equals(arg)
|
11
|
+
if (val.left == val.right)
|
12
|
+
val
|
13
|
+
end
|
14
|
+
}
|
15
|
+
rescue
|
16
|
+
return Evaluation.new(control.Text, arg)
|
17
|
+
end
|
14
18
|
|
15
|
-
return
|
19
|
+
return evaluation
|
16
20
|
end
|
17
21
|
end
|
18
22
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Sapphire
|
2
2
|
module Testing
|
3
3
|
module Coverage
|
4
|
-
def
|
5
|
-
$features.last().
|
4
|
+
def Behavior(token, hash)
|
5
|
+
$features.last().AddBehavior(Behavior.new(token, hash))
|
6
6
|
end
|
7
7
|
|
8
|
-
class
|
8
|
+
class Behavior
|
9
9
|
|
10
10
|
attr_reader :token
|
11
11
|
attr_reader :type
|
@@ -14,15 +14,15 @@ module Sapphire
|
|
14
14
|
|
15
15
|
def initialize(token)
|
16
16
|
@token = token
|
17
|
-
@
|
17
|
+
@behaviors = []
|
18
18
|
end
|
19
19
|
|
20
20
|
def AddRequirement(requirement)
|
21
21
|
@requirements << requirement
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
@requirements.last().
|
24
|
+
def AddBehavior(behavior)
|
25
|
+
@requirements.last().AddBehavior behavior
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
@@ -10,16 +10,16 @@ module Sapphire
|
|
10
10
|
|
11
11
|
attr_reader :token
|
12
12
|
attr_reader :priority
|
13
|
-
attr_reader :
|
13
|
+
attr_reader :behaviors
|
14
14
|
|
15
15
|
def initialize(hash)
|
16
16
|
@token = hash.keys.first
|
17
17
|
@priority = hash[hash.keys.first]
|
18
|
-
@
|
18
|
+
@behaviors = []
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
@
|
21
|
+
def AddBehavior(behavior)
|
22
|
+
@behaviors << behavior
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
data/lib/sapphire/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sapphire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-09 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|
16
|
-
requirement: &
|
16
|
+
requirement: &10000008 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *10000008
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colorize
|
27
|
-
requirement: &
|
27
|
+
requirement: &9999756 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *9999756
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: Platform
|
38
|
-
requirement: &
|
38
|
+
requirement: &9999504 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *9999504
|
47
47
|
description: An automated web acceptance test framework for non-technical resources
|
48
48
|
using selenium-wedriver.
|
49
49
|
email:
|
@@ -146,10 +146,10 @@ files:
|
|
146
146
|
- lib/sapphire/TeamCity/TeamCityReporter.rb
|
147
147
|
- lib/sapphire/TeamCity.rb
|
148
148
|
- lib/sapphire/Testing/ConsoleReporter.rb
|
149
|
+
- lib/sapphire/Testing/Coverage/Behavior.rb
|
149
150
|
- lib/sapphire/Testing/Coverage/Covers.rb
|
150
151
|
- lib/sapphire/Testing/Coverage/Feature.rb
|
151
152
|
- lib/sapphire/Testing/Coverage/Requirement.rb
|
152
|
-
- lib/sapphire/Testing/Coverage/Test.rb
|
153
153
|
- lib/sapphire/Testing/Executable.rb
|
154
154
|
- lib/sapphire/Testing/ExpectationException.rb
|
155
155
|
- lib/sapphire/Testing/HtmlReporter.rb
|