sapphire 0.7.12 → 0.7.14
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sapphire.rb +3 -2
- data/lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb +29 -24
- data/lib/sapphire/DSL/Evaluations/Evaluation.rb +4 -4
- data/lib/sapphire/DSL/TestPlans/TestPlan.rb +5 -1
- data/lib/sapphire/Testing/ConsoleReporter.rb +6 -1
- data/lib/sapphire/Testing/TestPlanResult.rb +24 -0
- data/lib/sapphire/WebAbstractions/Browsers/Chrome.rb +3 -1
- data/lib/sapphire/WebAbstractions/Browsers/FireFox.rb +1 -1
- data/lib/sapphire/WebAbstractions/Browsers/InternetExplorer.rb +1 -1
- data/lib/sapphire/WebAbstractions/Browsers/MetaBrowser.rb +22 -0
- data/lib/sapphire/WebAbstractions/Controls/Title.rb +1 -1
- data/lib/sapphire/version.rb +1 -1
- metadata +10 -8
data/lib/sapphire.rb
CHANGED
@@ -26,7 +26,6 @@ module Sapphire
|
|
26
26
|
include DSL::Configuration
|
27
27
|
include DSL::Data
|
28
28
|
include DSL::TestPlans
|
29
|
-
include DSL::Events
|
30
29
|
include Configuration
|
31
30
|
include DataAbstractions
|
32
31
|
include JobAbstractions
|
@@ -36,4 +35,6 @@ module Sapphire
|
|
36
35
|
include Testing::TeamCity
|
37
36
|
include UI
|
38
37
|
end
|
39
|
-
end
|
38
|
+
end
|
39
|
+
|
40
|
+
$driver = Sapphire::WebAbstractions::MetaBrowser.new(nil)
|
@@ -8,38 +8,43 @@ module Sapphire
|
|
8
8
|
@rootUrl = url
|
9
9
|
end
|
10
10
|
|
11
|
+
def Browser()
|
12
|
+
raise "Browser is null. Did you forget to start the browser?" if self.browser.nil?
|
13
|
+
self.browser
|
14
|
+
end
|
15
|
+
|
11
16
|
def Screenshot(file_name)
|
12
|
-
self.
|
17
|
+
self.Browser().save_screenshot(file_name)
|
13
18
|
end
|
14
19
|
|
15
20
|
def Close
|
16
|
-
self.
|
21
|
+
self.Browser().close
|
17
22
|
end
|
18
23
|
|
19
24
|
def Switch
|
20
|
-
self.
|
25
|
+
self.Browser().switch_to.window(self.Browser().window_handles[0])
|
21
26
|
end
|
22
27
|
|
23
28
|
def Type(keys)
|
24
|
-
self.
|
29
|
+
self.Browser().action.send_keys(keys).perform()
|
25
30
|
end
|
26
31
|
|
27
32
|
def AcceptAlert
|
28
|
-
alert = self.
|
33
|
+
alert = self.Browser().switch_to.alert
|
29
34
|
alert.accept()
|
30
|
-
self.
|
35
|
+
self.Browser().switch_to.window(self.Browser().window_handles[0])
|
31
36
|
end
|
32
37
|
|
33
38
|
def SetAlert(text)
|
34
|
-
alert = self.
|
39
|
+
alert = self.Browser().switch_to.alert
|
35
40
|
alert.send_keys(text)
|
36
41
|
alert.accept()
|
37
|
-
self.
|
42
|
+
self.Browser().switch_to.window(self.Browser().window_handles[0])
|
38
43
|
end
|
39
44
|
|
40
45
|
def FindAlert()
|
41
46
|
begin
|
42
|
-
return self.
|
47
|
+
return self.Browser().switch_to.alert
|
43
48
|
rescue
|
44
49
|
return nil
|
45
50
|
end
|
@@ -51,17 +56,17 @@ module Sapphire
|
|
51
56
|
end
|
52
57
|
|
53
58
|
def ClosePopup
|
54
|
-
self.
|
55
|
-
self.
|
56
|
-
self.
|
59
|
+
self.Browser().switch_to.window(self.Browser().window_handles.last)
|
60
|
+
self.Browser().close
|
61
|
+
self.Browser().switch_to.window(self.Browser().window_handles[0])
|
57
62
|
end
|
58
63
|
|
59
64
|
def SwitchToPopup
|
60
|
-
self.
|
65
|
+
self.Browser().switch_to.window(self.Browser().window_handles.last)
|
61
66
|
end
|
62
67
|
|
63
68
|
def SwitchToIFrame(frame)
|
64
|
-
self.
|
69
|
+
self.Browser().switch_to.frame(frame)
|
65
70
|
end
|
66
71
|
|
67
72
|
def SetRootUrl(url)
|
@@ -80,13 +85,13 @@ module Sapphire
|
|
80
85
|
$page = page
|
81
86
|
end
|
82
87
|
|
83
|
-
self.
|
88
|
+
self.Browser().get $page.Url
|
84
89
|
$page.Init
|
85
90
|
end
|
86
91
|
|
87
92
|
def CurrentUrl
|
88
93
|
wait = Selenium::WebDriver::Wait.new(:timeout => 20)
|
89
|
-
url = wait.until { x = self.
|
94
|
+
url = wait.until { x = self.Browser().current_url
|
90
95
|
x unless x == nil
|
91
96
|
}
|
92
97
|
|
@@ -94,7 +99,7 @@ module Sapphire
|
|
94
99
|
end
|
95
100
|
|
96
101
|
def Reload
|
97
|
-
self.
|
102
|
+
self.Browser().get self.CurrentUrl
|
98
103
|
end
|
99
104
|
|
100
105
|
def GetValue(item, key)
|
@@ -131,12 +136,12 @@ module Sapphire
|
|
131
136
|
begin
|
132
137
|
item = wait.until {
|
133
138
|
x = self.CurrentUrl.upcase.start_with?($page.Url.upcase)
|
134
|
-
y = StartsWithComparison.new(Evaluation.new(
|
139
|
+
y = StartsWithComparison.new(Evaluation.new(self.CurrentUrl.upcase, $page.Url.upcase))
|
135
140
|
if(comparator.Compare(x == false, true))
|
136
141
|
$page.AlternateUrls.each do |url|
|
137
142
|
if(comparator.Compare(x == false, true))
|
138
143
|
x = self.CurrentUrl.upcase.start_with?(url.upcase)
|
139
|
-
y = StartsWithComparison.new(Evaluation.new(
|
144
|
+
y = StartsWithComparison.new(Evaluation.new(self.CurrentUrl.upcase, url.upcase))
|
140
145
|
end
|
141
146
|
end
|
142
147
|
end
|
@@ -159,11 +164,11 @@ module Sapphire
|
|
159
164
|
|
160
165
|
def ShouldTransitionTo(url, comparator)
|
161
166
|
if(url.instance_of?(String))
|
162
|
-
temp = StartsWithComparison.new(Evaluation.new(
|
167
|
+
temp = StartsWithComparison.new(Evaluation.new(self.CurrentUrl.upcase, url.upcase))
|
163
168
|
@rootUrl = url
|
164
169
|
else
|
165
170
|
x = url.new().Url
|
166
|
-
temp = StartsWithComparison.new(Evaluation.new(
|
171
|
+
temp = StartsWithComparison.new(Evaluation.new(self.CurrentUrl.upcase, x.upcase))
|
167
172
|
@rootUrl = x
|
168
173
|
end
|
169
174
|
|
@@ -231,15 +236,15 @@ module Sapphire
|
|
231
236
|
end
|
232
237
|
|
233
238
|
def FindElement(discriminator, selector)
|
234
|
-
self.
|
239
|
+
self.Browser().find_element discriminator, selector
|
235
240
|
end
|
236
241
|
|
237
242
|
def FindElements(discriminator, selector)
|
238
|
-
self.
|
243
|
+
self.Browser().find_elements discriminator, selector
|
239
244
|
end
|
240
245
|
|
241
246
|
def ExecuteScript(script)
|
242
|
-
self.
|
247
|
+
self.Browser().execute_script(script)
|
243
248
|
end
|
244
249
|
|
245
250
|
def Create(type)
|
@@ -32,10 +32,10 @@ module Sapphire
|
|
32
32
|
if(!Compare(@left, @right))
|
33
33
|
messages = []
|
34
34
|
|
35
|
-
messages << "expected" + @comparator.Text + ": (nil)" if @
|
36
|
-
messages << "expected" + @comparator.Text + ": " + @
|
37
|
-
messages << "got: (nil)" if @
|
38
|
-
messages << "got: " + @
|
35
|
+
messages << "expected" + @comparator.Text + ": (nil)" if @right == nil
|
36
|
+
messages << "expected" + @comparator.Text + ": " + @right.to_s if @right != nil
|
37
|
+
messages << "got: (nil)" if @left == nil
|
38
|
+
messages << "got: " + @left.to_s if @left != nil
|
39
39
|
|
40
40
|
raise ExpectationException.new(messages)
|
41
41
|
end
|
@@ -48,7 +48,11 @@ module Sapphire
|
|
48
48
|
def execute
|
49
49
|
Report do |x| x.BeginTesting end
|
50
50
|
$stdout.puts ""
|
51
|
-
|
51
|
+
begin
|
52
|
+
@block.call
|
53
|
+
rescue => e
|
54
|
+
Report do |x| x.TestFailed TestPlanResult.new('fail', self, e.message, e.backtrace, 0) end
|
55
|
+
end
|
52
56
|
Report do |x| x.TestingComplete end
|
53
57
|
Report do |x| x.OutputResults end
|
54
58
|
end
|
@@ -53,7 +53,7 @@ module Sapphire
|
|
53
53
|
end
|
54
54
|
@output.puts ""
|
55
55
|
result.stack.each do |line|
|
56
|
-
if (!line.include? "sapphire")
|
56
|
+
if (!line.include? "sapphire" and ! line.include? "-e:1")
|
57
57
|
Indent(depth+1)
|
58
58
|
@output.puts line
|
59
59
|
end
|
@@ -108,6 +108,8 @@ module Sapphire
|
|
108
108
|
@not_passing = @not_passing.merge!({ r.parent.parent => r.parent.parent })
|
109
109
|
elsif !result_passes and (r.item.is_a? And and r.parent.item.is_a? Then)
|
110
110
|
@not_passing = @not_passing.merge!({ r.parent.parent.parent => r.parent.parent.parent })
|
111
|
+
elsif r.item.is_a? TestPlan
|
112
|
+
@not_passing = @not_passing.merge!({ r => r })
|
111
113
|
end
|
112
114
|
|
113
115
|
end
|
@@ -151,6 +153,9 @@ module Sapphire
|
|
151
153
|
self.PrintItem entry.parent, 0
|
152
154
|
self.Output entry, 1
|
153
155
|
self.InsertLineBreak
|
156
|
+
elsif entry.item.is_a? TestPlan
|
157
|
+
self.PrintItem entry, 0
|
158
|
+
self.InsertLineBreak
|
154
159
|
else
|
155
160
|
self.PrintResult entry.parent
|
156
161
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Sapphire
|
2
|
+
module Testing
|
3
|
+
class TestPlanResult
|
4
|
+
|
5
|
+
attr_reader :execution_time
|
6
|
+
attr_reader :message
|
7
|
+
attr_reader :item
|
8
|
+
attr_reader :type
|
9
|
+
attr_reader :stack
|
10
|
+
attr_reader :messages
|
11
|
+
attr_reader :text
|
12
|
+
|
13
|
+
def initialize(type, item, message, stack, execution_time)
|
14
|
+
@item = item
|
15
|
+
@text = "Failure running commands in TestPlan: " + item.text
|
16
|
+
@execution_time = execution_time
|
17
|
+
@messages = message
|
18
|
+
@stack = stack
|
19
|
+
@type = type
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Sapphire
|
2
|
+
module WebAbstractions
|
3
|
+
|
4
|
+
class MetaBrowser
|
5
|
+
include RubySeleniumWebDriver
|
6
|
+
|
7
|
+
attr_reader :driver
|
8
|
+
|
9
|
+
def initialize(driver)
|
10
|
+
@driver = driver
|
11
|
+
end
|
12
|
+
|
13
|
+
def Browser()
|
14
|
+
raise "Browser is null. Did you forget to start the browser?" if self.driver.nil? or self.driver.browser.nil?
|
15
|
+
self.driver.browser
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
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.7.
|
4
|
+
version: 0.7.14
|
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: 2012-03-
|
12
|
+
date: 2012-03-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|
16
|
-
requirement: &
|
16
|
+
requirement: &9813300 !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: *9813300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colorize
|
27
|
-
requirement: &
|
27
|
+
requirement: &9813048 !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: *9813048
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: Platform
|
38
|
-
requirement: &
|
38
|
+
requirement: &9812796 !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: *9812796
|
47
47
|
description: An automated web acceptance test framework for non-technical resources
|
48
48
|
using selenium-wedriver.
|
49
49
|
email:
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- lib/sapphire/Testing/ResultList.rb
|
181
181
|
- lib/sapphire/Testing/ResultTree.rb
|
182
182
|
- lib/sapphire/Testing/ScenarioResult.rb
|
183
|
+
- lib/sapphire/Testing/TestPlanResult.rb
|
183
184
|
- lib/sapphire/Testing/TestResult.rb
|
184
185
|
- lib/sapphire/Testing/TestRunnerAdapter.rb
|
185
186
|
- lib/sapphire/Testing.rb
|
@@ -192,6 +193,7 @@ files:
|
|
192
193
|
- lib/sapphire/WebAbstractions/Browsers/Chrome.rb
|
193
194
|
- lib/sapphire/WebAbstractions/Browsers/FireFox.rb
|
194
195
|
- lib/sapphire/WebAbstractions/Browsers/InternetExplorer.rb
|
196
|
+
- lib/sapphire/WebAbstractions/Browsers/MetaBrowser.rb
|
195
197
|
- lib/sapphire/WebAbstractions/Controls/AlertBox.rb
|
196
198
|
- lib/sapphire/WebAbstractions/Controls/Base/Control.rb
|
197
199
|
- lib/sapphire/WebAbstractions/Controls/Base/Page.rb
|