sapphire 0.6.5 → 0.6.7
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 +4 -4
- data/lib/sapphire/DSL.rb +1 -1
- data/lib/sapphire/DSL/Browser/Extensions/String.rb +20 -0
- data/lib/sapphire/DSL/Browser/Extensions/Symbol.rb +3 -3
- data/lib/sapphire/DSL/Browser/Should.rb +56 -42
- data/lib/sapphire/DSL/Browser/Verbs/Attempt.rb +14 -0
- data/lib/sapphire/DSL/Browser/Verbs/Contain.rb +25 -0
- data/lib/sapphire/DSL/Browser/Verbs/Count.rb +24 -0
- data/lib/sapphire/DSL/TestPlans/Parameter.rb +38 -0
- data/lib/sapphire/Strategies/ContainsEvaluation.rb +16 -0
- data/lib/sapphire/Strategies/ContainsNullModifier.rb +34 -0
- data/lib/sapphire/Strategies/HashStrategy.rb +38 -1
- data/lib/sapphire/Strategies/SymbolStrategy.rb +2 -2
- data/lib/sapphire/Testing/Executable.rb +9 -9
- data/lib/sapphire/WebAbstractions/Controls/Base/Control.rb +62 -58
- data/lib/sapphire/WebAbstractions/Controls/Base/Page.rb +4 -0
- data/lib/sapphire/WebAbstractions/Controls/List.rb +34 -0
- data/lib/sapphire/version.rb +1 -1
- metadata +15 -9
- data/lib/sapphire/DSL/Data/Underscore.rb +0 -9
@@ -69,7 +69,7 @@ module Sapphire
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def CurrentUrl
|
72
|
-
wait = Selenium::WebDriver::Wait.new(:timeout =>
|
72
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 20)
|
73
73
|
url = wait.until { x = self.browser.current_url
|
74
74
|
x unless x == nil
|
75
75
|
}
|
@@ -88,7 +88,7 @@ module Sapphire
|
|
88
88
|
nav = page
|
89
89
|
end
|
90
90
|
|
91
|
-
wait = Selenium::WebDriver::Wait.new(:timeout =>
|
91
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 20)
|
92
92
|
begin
|
93
93
|
found = wait.until {
|
94
94
|
x = self.CurrentUrl.upcase.start_with?("HTTP://" + nav.Url.upcase) || self.CurrentUrl.upcase.start_with?("HTTPS://" + nav.Url.upcase)
|
@@ -133,7 +133,7 @@ module Sapphire
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def FindItem(array)
|
136
|
-
masterWait = Selenium::WebDriver::Wait.new(:timeout =>
|
136
|
+
masterWait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
137
137
|
|
138
138
|
element = masterWait.until {
|
139
139
|
x = nil
|
@@ -161,7 +161,7 @@ module Sapphire
|
|
161
161
|
end
|
162
162
|
|
163
163
|
def FindAllItems(array)
|
164
|
-
masterWait = Selenium::WebDriver::Wait.new(:timeout =>
|
164
|
+
masterWait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
165
165
|
|
166
166
|
element = masterWait.until {
|
167
167
|
x = nil
|
data/lib/sapphire/DSL.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
Dir[File.dirname(__FILE__) + '/DSL/TestPlans/*.rb'].each {|file| require file }
|
1
2
|
Dir[File.dirname(__FILE__) + '/DSL/Browser/*.rb'].each {|file| require file }
|
2
3
|
Dir[File.dirname(__FILE__) + '/DSL/Browser/Fluff/*.rb'].each {|file| require file }
|
3
4
|
Dir[File.dirname(__FILE__) + '/DSL/Browser/Extensions/*.rb'].each {|file| require file }
|
@@ -7,4 +8,3 @@ Dir[File.dirname(__FILE__) + '/DSL/Browser/Keys/*.rb'].each {|file| require file
|
|
7
8
|
Dir[File.dirname(__FILE__) + '/DSL/Configuration/*.rb'].each {|file| require file }
|
8
9
|
Dir[File.dirname(__FILE__) + '/DSL/Data/*.rb'].each {|file| require file }
|
9
10
|
Dir[File.dirname(__FILE__) + '/DSL/Scenarios/*.rb'].each {|file| require file }
|
10
|
-
Dir[File.dirname(__FILE__) + '/DSL/TestPlans/*.rb'].each {|file| require file }
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class String
|
2
|
+
|
3
|
+
alias_method :"plus", :"+"
|
4
|
+
|
5
|
+
def underscore
|
6
|
+
self.gsub(/::/, '/').
|
7
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
8
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
9
|
+
tr("-", "_").
|
10
|
+
downcase
|
11
|
+
end
|
12
|
+
|
13
|
+
def +(item)
|
14
|
+
return plus(Parameter(item)) if Sapphire::DSL::TestPlans::Parameters.instance.Contains(item)
|
15
|
+
raise "No Parameter defined for: " << item.to_s if item.is_a? Symbol
|
16
|
+
|
17
|
+
plus(item)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -1,42 +1,56 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module DSL
|
3
|
-
module Browser
|
4
|
-
def Should(item)
|
5
|
-
results = item.execute()
|
6
|
-
|
7
|
-
if results.is_a? Hash
|
8
|
-
@page = results[:page] if results[:page] != nil
|
9
|
-
value = results[:value]
|
10
|
-
modifier = results[:modifier]
|
11
|
-
|
12
|
-
if value.is_a? Hash
|
13
|
-
@page = value[:page] if value[:page] != nil
|
14
|
-
sub_value = value[:value]
|
15
|
-
modifier.Evaluate(sub_value)
|
16
|
-
return
|
17
|
-
end
|
18
|
-
modifier.Evaluate(value)
|
19
|
-
|
20
|
-
return
|
21
|
-
end
|
22
|
-
|
23
|
-
if(results.is_a? Evaluation)
|
24
|
-
if(results.left != results.right)
|
25
|
-
messages = []
|
26
|
-
|
27
|
-
messages << "expected: (nil)" if results.left == nil
|
28
|
-
messages << "expected: " + results.left.to_s if results.left != nil
|
29
|
-
messages << "got: (nil)" if results.right == nil
|
30
|
-
messages << "got: " + results.right.to_s if results.right != nil
|
31
|
-
|
32
|
-
raise ExpectationException.new(messages)
|
33
|
-
end
|
34
|
-
return
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
1
|
+
module Sapphire
|
2
|
+
module DSL
|
3
|
+
module Browser
|
4
|
+
def Should(item)
|
5
|
+
results = item.execute()
|
6
|
+
|
7
|
+
if results.is_a? Hash
|
8
|
+
@page = results[:page] if results[:page] != nil
|
9
|
+
value = results[:value]
|
10
|
+
modifier = results[:modifier]
|
11
|
+
|
12
|
+
if value.is_a? Hash
|
13
|
+
@page = value[:page] if value[:page] != nil
|
14
|
+
sub_value = value[:value]
|
15
|
+
modifier.Evaluate(sub_value)
|
16
|
+
return
|
17
|
+
end
|
18
|
+
modifier.Evaluate(value)
|
19
|
+
|
20
|
+
return
|
21
|
+
end
|
22
|
+
|
23
|
+
if(results.is_a? Evaluation)
|
24
|
+
if(results.left != results.right)
|
25
|
+
messages = []
|
26
|
+
|
27
|
+
messages << "expected: (nil)" if results.left == nil
|
28
|
+
messages << "expected: " + results.left.to_s if results.left != nil
|
29
|
+
messages << "got: (nil)" if results.right == nil
|
30
|
+
messages << "got: " + results.right.to_s if results.right != nil
|
31
|
+
|
32
|
+
raise ExpectationException.new(messages)
|
33
|
+
end
|
34
|
+
return
|
35
|
+
end
|
36
|
+
|
37
|
+
if(results.is_a? ContainsEvaluation)
|
38
|
+
if(!results.left.include? results.right)
|
39
|
+
messages = []
|
40
|
+
|
41
|
+
messages << "expected to contain: (nil)" if results.left == nil
|
42
|
+
messages << "expected to contain: " + results.left.to_s if results.left != nil
|
43
|
+
messages << "got: (nil)" if results.right == nil
|
44
|
+
messages << "got: " + results.right.to_s if results.right != nil
|
45
|
+
|
46
|
+
raise ExpectationException.new(messages)
|
47
|
+
end
|
48
|
+
return
|
49
|
+
end
|
50
|
+
|
51
|
+
raise "Cannot act upon result " + results.to_s + " for page " + @page.to_s
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Sapphire
|
2
|
+
module DSL
|
3
|
+
module Browser
|
4
|
+
def Contain(item)
|
5
|
+
ContainsNullModifier.new(Contain.new(item, @page))
|
6
|
+
end
|
7
|
+
|
8
|
+
class Contain
|
9
|
+
def initialize(item, page)
|
10
|
+
@item = item
|
11
|
+
@page = page
|
12
|
+
end
|
13
|
+
|
14
|
+
def ModifyWith(item)
|
15
|
+
@modifier = item
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute
|
19
|
+
return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page).Contain(@item, @modifier), :modifier => @modifier }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Sapphire
|
2
|
+
module DSL
|
3
|
+
module Browser
|
4
|
+
def Count(item)
|
5
|
+
NullModifier.new(Count.new(item, @page))
|
6
|
+
end
|
7
|
+
|
8
|
+
class Count
|
9
|
+
def initialize(item, page)
|
10
|
+
@item = item
|
11
|
+
@page = page
|
12
|
+
end
|
13
|
+
|
14
|
+
def ModifyWith(item)
|
15
|
+
@modifier = item
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute
|
19
|
+
return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page).Count(@item, @modifier), :modifier => @modifier }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Sapphire
|
2
|
+
module DSL
|
3
|
+
module TestPlans
|
4
|
+
|
5
|
+
def Parameter(item)
|
6
|
+
Parameters.instance.Add(item) if item.is_a? Hash
|
7
|
+
return Parameters.instance.Get(item) if item.is_a? Symbol
|
8
|
+
end
|
9
|
+
|
10
|
+
class Parameters
|
11
|
+
def self.create
|
12
|
+
@@instance ||= Parameters.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.instance
|
16
|
+
@@instance ||= self.create
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize()
|
20
|
+
$parameters ||= {}
|
21
|
+
end
|
22
|
+
|
23
|
+
def Add(item)
|
24
|
+
$parameters.merge! item
|
25
|
+
end
|
26
|
+
|
27
|
+
def Contains(item)
|
28
|
+
$parameters.has_key? item
|
29
|
+
end
|
30
|
+
|
31
|
+
def Get(item)
|
32
|
+
$parameters[item]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class ContainsNullModifier
|
2
|
+
def initialize(item)
|
3
|
+
@item = item
|
4
|
+
@item.ModifyWith self
|
5
|
+
end
|
6
|
+
|
7
|
+
def ModifyWith(item)
|
8
|
+
@modifier = item
|
9
|
+
end
|
10
|
+
|
11
|
+
def Modify(item)
|
12
|
+
return @modifier.Modify(item) if @modifier != nil
|
13
|
+
item if @modifier == nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def Evaluate(evaluation)
|
17
|
+
return @modifier.Evaluate(evaluation) if @modifier != nil
|
18
|
+
|
19
|
+
if(!evaluation.left.include? evaluation.right)
|
20
|
+
messages = []
|
21
|
+
|
22
|
+
messages << "expected to contain: (nil)" if evaluation.right == nil
|
23
|
+
messages << "expected to contain: " + evaluation.right.to_s if evaluation.right != nil
|
24
|
+
messages << "got: (nil)" if evaluation.left == nil
|
25
|
+
messages << "got: " + evaluation.left.to_s if evaluation.left != nil
|
26
|
+
|
27
|
+
raise ExpectationException.new(messages)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def execute
|
32
|
+
@item.execute
|
33
|
+
end
|
34
|
+
end
|
@@ -4,7 +4,7 @@ module Sapphire
|
|
4
4
|
class HashStrategy < Strategy
|
5
5
|
def Show(item, modifier)
|
6
6
|
ExecuteHashAgainstControl(item, @page) do |control, arg|
|
7
|
-
wait = Selenium::WebDriver::Wait.new(:timeout =>
|
7
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
8
8
|
begin
|
9
9
|
evaluation = wait.until { x = control
|
10
10
|
val = x.Equals(arg)
|
@@ -20,6 +20,43 @@ module Sapphire
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def Contain(item, modifier)
|
24
|
+
ExecuteHashAgainstControl(item, @page) do |control, arg|
|
25
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
26
|
+
begin
|
27
|
+
evaluation = wait.until { x = control
|
28
|
+
val = x.Contain(arg)
|
29
|
+
if (val.left.include? val.right)
|
30
|
+
return val
|
31
|
+
end
|
32
|
+
}
|
33
|
+
rescue
|
34
|
+
return ContainsEvaluation.new(control.Text, arg)
|
35
|
+
end
|
36
|
+
|
37
|
+
return evaluation
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def Count(item, modifier)
|
42
|
+
ExecuteHashAgainstControl(item, @page) do |control, arg|
|
43
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
44
|
+
count = 0
|
45
|
+
begin
|
46
|
+
evaluation = wait.until { x = control
|
47
|
+
count = x.Count
|
48
|
+
if x.Count == arg
|
49
|
+
return Evaluation.new(count, arg)
|
50
|
+
end
|
51
|
+
}
|
52
|
+
rescue
|
53
|
+
return Evaluation.new(count, arg)
|
54
|
+
end
|
55
|
+
|
56
|
+
return evaluation
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
23
60
|
def Validate(hash)
|
24
61
|
Evaluation.new(hash.keys.first.to_s, hash[hash.keys.first].to_s)
|
25
62
|
end
|
@@ -10,7 +10,7 @@ module Sapphire
|
|
10
10
|
x = field[field_key].Find
|
11
11
|
if(x)
|
12
12
|
begin
|
13
|
-
wait = Selenium::WebDriver::Wait.new(:timeout =>
|
13
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
14
14
|
result = wait.until { y = modifier.Modify(x.displayed?)
|
15
15
|
y unless y == false
|
16
16
|
}
|
@@ -34,7 +34,7 @@ module Sapphire
|
|
34
34
|
field.keys.each do |field_key|
|
35
35
|
if(field_key == item)
|
36
36
|
begin
|
37
|
-
wait = Selenium::WebDriver::Wait.new(:timeout =>
|
37
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
38
38
|
element = wait.until { x = field[field_key].Find
|
39
39
|
x and modifier.Modify(!x.displayed?)
|
40
40
|
}
|
@@ -11,12 +11,6 @@ module Sapphire
|
|
11
11
|
Report do |x| x.TestPending(result) end
|
12
12
|
return
|
13
13
|
end
|
14
|
-
if(self.value.is_a? Problematic)
|
15
|
-
result = ResultTree.new(self.text, TestResult.new("problematic", self, "Problematic", "", Time.now - start))
|
16
|
-
self.AddResult(result)
|
17
|
-
Report do |x| x.TestProblematic(result) end
|
18
|
-
return
|
19
|
-
end
|
20
14
|
self.block.call
|
21
15
|
result = ResultTree.new(self.text, TestResult.new("pass", self, "Success", "", Time.now - start))
|
22
16
|
self.AddResult(result)
|
@@ -25,9 +19,15 @@ module Sapphire
|
|
25
19
|
stack = msg.backtrace
|
26
20
|
message = msg.messages if (msg.is_a? ExpectationException)
|
27
21
|
message ||= msg.message
|
28
|
-
|
29
|
-
|
30
|
-
|
22
|
+
if(self.value.is_a? Problematic)
|
23
|
+
result = ResultTree.new(self.text, TestResult.new("problematic", self, message, stack, Time.now - start))
|
24
|
+
self.AddResult(result)
|
25
|
+
Report do |x| x.TestProblematic(result) end
|
26
|
+
else
|
27
|
+
result = ResultTree.new(self.text, TestResult.new("fail", self, message, stack, Time.now - start))
|
28
|
+
self.AddResult(result)
|
29
|
+
Report do |x| x.TestFailed(result) end
|
30
|
+
end
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -1,58 +1,62 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module WebAbstractions
|
3
|
-
class Control
|
4
|
-
def initialize(hash)
|
5
|
-
@hash = hash
|
6
|
-
end
|
7
|
-
|
8
|
-
def Find
|
9
|
-
$browser.FindItem(@hash)
|
10
|
-
end
|
11
|
-
|
12
|
-
def FindAll
|
13
|
-
$browser.FindAllItems(@hash)
|
14
|
-
end
|
15
|
-
|
16
|
-
def FindWithoutWait
|
17
|
-
$browser.FindElement @hash[0].keys.first, @hash[0].fetch(@hash[0].keys.first)
|
18
|
-
end
|
19
|
-
|
20
|
-
def Text
|
21
|
-
text = self.Find
|
22
|
-
text.text
|
23
|
-
end
|
24
|
-
|
25
|
-
def Click
|
26
|
-
control = self.Find
|
27
|
-
control.click
|
28
|
-
end
|
29
|
-
|
30
|
-
def MouseOver
|
31
|
-
if @hash.is_a? Hash
|
32
|
-
if(@hash.has_key?(:id))
|
33
|
-
$browser.ExecuteScript("document.getElementById('"+ @hash.fetch(:id) +"').style.visibility = 'visible'; ")
|
34
|
-
elsif (@hash.has_key?(:name))
|
35
|
-
$browser.ExecuteScript("document.getElementByName('"+ @hash.fetch(:name) +"').style.visibility = 'visible'; ")
|
36
|
-
elsif (@hash.has_key?(:xpath))
|
37
|
-
$browser.ExecuteScript("document.evaluate( '" + @hash.fetch(:xpath) + "', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.visibility = 'visible'; ")
|
38
|
-
end
|
39
|
-
elsif @hash.is_a? Array
|
40
|
-
if(@hash[0].has_key?(:id))
|
41
|
-
$browser.ExecuteScript("document.getElementById('"+ @hash[0].fetch(:id) +"').style.visibility = 'visible'; ")
|
42
|
-
elsif (@hash[0].has_key?(:name))
|
43
|
-
$browser.ExecuteScript("document.getElementByName('"+ @hash[0].fetch(:name) +"').style.visibility = 'visible'; ")
|
44
|
-
elsif (@hash[0].has_key?(:xpath))
|
45
|
-
$browser.ExecuteScript("document.evaluate( '" + @hash[0].fetch(:xpath) + "', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.visibility = 'visible'; ")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
sleep(1)
|
50
|
-
end
|
51
|
-
|
52
|
-
def Equals(value)
|
53
|
-
Evaluation.new(self.Text, value)
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
1
|
+
module Sapphire
|
2
|
+
module WebAbstractions
|
3
|
+
class Control
|
4
|
+
def initialize(hash)
|
5
|
+
@hash = hash
|
6
|
+
end
|
7
|
+
|
8
|
+
def Find
|
9
|
+
$browser.FindItem(@hash)
|
10
|
+
end
|
11
|
+
|
12
|
+
def FindAll
|
13
|
+
$browser.FindAllItems(@hash)
|
14
|
+
end
|
15
|
+
|
16
|
+
def FindWithoutWait
|
17
|
+
$browser.FindElement @hash[0].keys.first, @hash[0].fetch(@hash[0].keys.first)
|
18
|
+
end
|
19
|
+
|
20
|
+
def Text
|
21
|
+
text = self.Find
|
22
|
+
text.text
|
23
|
+
end
|
24
|
+
|
25
|
+
def Click
|
26
|
+
control = self.Find
|
27
|
+
control.click
|
28
|
+
end
|
29
|
+
|
30
|
+
def MouseOver
|
31
|
+
if @hash.is_a? Hash
|
32
|
+
if(@hash.has_key?(:id))
|
33
|
+
$browser.ExecuteScript("document.getElementById('"+ @hash.fetch(:id) +"').style.visibility = 'visible'; ")
|
34
|
+
elsif (@hash.has_key?(:name))
|
35
|
+
$browser.ExecuteScript("document.getElementByName('"+ @hash.fetch(:name) +"').style.visibility = 'visible'; ")
|
36
|
+
elsif (@hash.has_key?(:xpath))
|
37
|
+
$browser.ExecuteScript("document.evaluate( '" + @hash.fetch(:xpath) + "', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.visibility = 'visible'; ")
|
38
|
+
end
|
39
|
+
elsif @hash.is_a? Array
|
40
|
+
if(@hash[0].has_key?(:id))
|
41
|
+
$browser.ExecuteScript("document.getElementById('"+ @hash[0].fetch(:id) +"').style.visibility = 'visible'; ")
|
42
|
+
elsif (@hash[0].has_key?(:name))
|
43
|
+
$browser.ExecuteScript("document.getElementByName('"+ @hash[0].fetch(:name) +"').style.visibility = 'visible'; ")
|
44
|
+
elsif (@hash[0].has_key?(:xpath))
|
45
|
+
$browser.ExecuteScript("document.evaluate( '" + @hash[0].fetch(:xpath) + "', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.visibility = 'visible'; ")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
sleep(1)
|
50
|
+
end
|
51
|
+
|
52
|
+
def Equals(value)
|
53
|
+
return Evaluation.new(self.Text, value)
|
54
|
+
end
|
55
|
+
|
56
|
+
def Contain(value)
|
57
|
+
return ContainsEvaluation.new(self.Text, value)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
@@ -2,6 +2,11 @@ module Sapphire
|
|
2
2
|
module WebAbstractions
|
3
3
|
class List < Control
|
4
4
|
|
5
|
+
def initialize(hash)
|
6
|
+
@hash = hash
|
7
|
+
@retryAttempts = 0
|
8
|
+
end
|
9
|
+
|
5
10
|
def Equals(value)
|
6
11
|
x = self.FindAll
|
7
12
|
x.each do |item|
|
@@ -11,6 +16,35 @@ module Sapphire
|
|
11
16
|
end
|
12
17
|
return Evaluation.new("Value not found in list", value)
|
13
18
|
end
|
19
|
+
|
20
|
+
def Click
|
21
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 3)
|
22
|
+
begin
|
23
|
+
clicked = wait.until { items = self.FindAll
|
24
|
+
if items.empty? == false
|
25
|
+
if items.first.displayed? == true
|
26
|
+
items.first.click
|
27
|
+
return true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
}
|
31
|
+
return nil
|
32
|
+
rescue
|
33
|
+
#retry a few times because in strange events from finding all the elements to trying to click one, it can become
|
34
|
+
#unavailable
|
35
|
+
if(@retryAttempts < 2)
|
36
|
+
@retryAttempts = @retryAttempts + 1
|
37
|
+
self.Click
|
38
|
+
else
|
39
|
+
return nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def Count
|
45
|
+
items = self.FindAll
|
46
|
+
return items.count
|
47
|
+
end
|
14
48
|
end
|
15
49
|
end
|
16
50
|
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.6.
|
4
|
+
version: 0.6.7
|
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-01-
|
12
|
+
date: 2012-01-26 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|
16
|
-
requirement: &
|
16
|
+
requirement: &10068828 !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: *10068828
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colorize
|
27
|
-
requirement: &
|
27
|
+
requirement: &10068576 !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: *10068576
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: Platform
|
38
|
-
requirement: &
|
38
|
+
requirement: &10068324 !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: *10068324
|
47
47
|
description: An automated web acceptance test framework for non-technical resources
|
48
48
|
using selenium-wedriver.
|
49
49
|
email:
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/sapphire/DSL/Browser/Extensions/Class.rb
|
70
70
|
- lib/sapphire/DSL/Browser/Extensions/Hash.rb
|
71
71
|
- lib/sapphire/DSL/Browser/Extensions/Numeric.rb
|
72
|
+
- lib/sapphire/DSL/Browser/Extensions/String.rb
|
72
73
|
- lib/sapphire/DSL/Browser/Extensions/Symbol.rb
|
73
74
|
- lib/sapphire/DSL/Browser/Fluff/By.rb
|
74
75
|
- lib/sapphire/DSL/Browser/Fluff/To.rb
|
@@ -84,12 +85,15 @@ files:
|
|
84
85
|
- lib/sapphire/DSL/Browser/Should.rb
|
85
86
|
- lib/sapphire/DSL/Browser/Tracker.rb
|
86
87
|
- lib/sapphire/DSL/Browser/Verbs/Accept.rb
|
88
|
+
- lib/sapphire/DSL/Browser/Verbs/Attempt.rb
|
87
89
|
- lib/sapphire/DSL/Browser/Verbs/Check.rb
|
88
90
|
- lib/sapphire/DSL/Browser/Verbs/Clear.rb
|
89
91
|
- lib/sapphire/DSL/Browser/Verbs/Click.rb
|
90
92
|
- lib/sapphire/DSL/Browser/Verbs/Close.rb
|
91
93
|
- lib/sapphire/DSL/Browser/Verbs/Compare.rb
|
92
94
|
- lib/sapphire/DSL/Browser/Verbs/Complete.rb
|
95
|
+
- lib/sapphire/DSL/Browser/Verbs/Contain.rb
|
96
|
+
- lib/sapphire/DSL/Browser/Verbs/Count.rb
|
93
97
|
- lib/sapphire/DSL/Browser/Verbs/Differ.rb
|
94
98
|
- lib/sapphire/DSL/Browser/Verbs/Disable.rb
|
95
99
|
- lib/sapphire/DSL/Browser/Verbs/Error.rb
|
@@ -113,7 +117,6 @@ files:
|
|
113
117
|
- lib/sapphire/DSL/Data/Exist.rb
|
114
118
|
- lib/sapphire/DSL/Data/Find.rb
|
115
119
|
- lib/sapphire/DSL/Data/GetPageField.rb
|
116
|
-
- lib/sapphire/DSL/Data/Underscore.rb
|
117
120
|
- lib/sapphire/DSL/Data/Validate.rb
|
118
121
|
- lib/sapphire/DSL/Data/Verify.rb
|
119
122
|
- lib/sapphire/DSL/Data/Write.rb
|
@@ -131,12 +134,15 @@ files:
|
|
131
134
|
- lib/sapphire/DSL/Scenarios/when.rb
|
132
135
|
- lib/sapphire/DSL/TestPlans/Covers.rb
|
133
136
|
- lib/sapphire/DSL/TestPlans/FileHandler.rb
|
137
|
+
- lib/sapphire/DSL/TestPlans/Parameter.rb
|
134
138
|
- lib/sapphire/DSL/TestPlans/PathHandler.rb
|
135
139
|
- lib/sapphire/DSL/TestPlans/Run.rb
|
136
140
|
- lib/sapphire/DSL/TestPlans/TestPlan.rb
|
137
141
|
- lib/sapphire/DSL.rb
|
138
142
|
- lib/sapphire/JobAbstractions/Job.rb
|
139
143
|
- lib/sapphire/Strategies/ClassStrategy.rb
|
144
|
+
- lib/sapphire/Strategies/ContainsEvaluation.rb
|
145
|
+
- lib/sapphire/Strategies/ContainsNullModifier.rb
|
140
146
|
- lib/sapphire/Strategies/DefaultStrategy.rb
|
141
147
|
- lib/sapphire/Strategies/Evaluation.rb
|
142
148
|
- lib/sapphire/Strategies/HashStrategy.rb
|