sapphire 0.7.3 → 0.7.4
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 +27 -6
- data/lib/sapphire/DSL/Browser/Nouns/Second.rb +1 -1
- data/lib/sapphire/DSL/Browser/Verbs/Remove.rb +0 -1
- data/lib/sapphire/DSL/Comparisons/Comparison.rb +8 -0
- data/lib/sapphire/DSL/Evaluators/Show.rb +2 -2
- data/lib/sapphire/Extensions/Hash.rb +5 -22
- data/lib/sapphire/Extensions/Symbol.rb +10 -24
- data/lib/sapphire/UI/Functions.rb +0 -1
- data/lib/sapphire/WebAbstractions/Controls/AlertBox.rb +1 -1
- data/lib/sapphire/WebAbstractions/Controls/Base/Control.rb +40 -1
- data/lib/sapphire/WebAbstractions/Controls/CheckBox.rb +2 -2
- data/lib/sapphire/WebAbstractions/Controls/List.rb +8 -1
- data/lib/sapphire/WebAbstractions/Controls/RadioButton.rb +2 -2
- data/lib/sapphire/version.rb +1 -1
- metadata +8 -8
@@ -93,16 +93,37 @@ module Sapphire
|
|
93
93
|
self.browser.get self.CurrentUrl
|
94
94
|
end
|
95
95
|
|
96
|
-
def
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
def GetValue(item, key)
|
97
|
+
|
98
|
+
if item.is_a? Array
|
99
|
+
item.each do |sub_item|
|
100
|
+
value = GetValue(sub_item, key)
|
101
|
+
return value if !value.nil?
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
if item.is_a? Class and key.nil?
|
106
|
+
return item.new
|
101
107
|
end
|
102
108
|
|
109
|
+
if item.is_a? Hash
|
110
|
+
return item[key] if item.has_key? key
|
111
|
+
end
|
112
|
+
|
113
|
+
nil
|
114
|
+
end
|
115
|
+
|
116
|
+
def ShouldNavigateTo(page, comparator)
|
117
|
+
|
118
|
+
$page = GetValue(page, nil)
|
119
|
+
$page ||= page
|
120
|
+
|
121
|
+
timeout = GetValue(page, :wait)
|
122
|
+
timeout ||= 20
|
123
|
+
|
103
124
|
$page.Init
|
104
125
|
|
105
|
-
wait = Selenium::WebDriver::Wait.new(:timeout =>
|
126
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => timeout)
|
106
127
|
begin
|
107
128
|
item = wait.until {
|
108
129
|
x = self.CurrentUrl.upcase.start_with?($page.Url.upcase)
|
@@ -26,7 +26,7 @@ module Sapphire
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def Differ(comparator)
|
29
|
-
return Fix(DifferComparison.new(Evaluation.new(@
|
29
|
+
return Fix(DifferComparison.new(Evaluation.new((@compare2 - @compare1).to_i, @value)), comparator)
|
30
30
|
end
|
31
31
|
|
32
32
|
def Fix(evaluation, comparator)
|
@@ -9,32 +9,15 @@ class Hash < Object
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def Examine(item, comparator, &block)
|
12
|
-
key = item.keys.first
|
13
|
-
|
14
|
-
value = item[key]
|
12
|
+
key = item.first.keys.first if item.first.is_a? Hash
|
13
|
+
key = item.first.first if item.first.is_a? Array
|
15
14
|
|
16
15
|
return FieldNotDefinedEvaluation.new(key, $page) if !$page.Contains key
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
begin
|
22
|
-
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
23
|
-
result = wait.until {
|
24
|
-
evaluation = block.call(field, value)
|
25
|
-
y = evaluation.Evaluate()
|
26
|
-
comparator = EqualsComparison.new(evaluation) if evaluation == nil
|
27
|
-
evaluation if comparator.Compare(y == true, true)
|
28
|
-
}
|
29
|
-
|
30
|
-
return Fix(result, comparator)
|
31
|
-
rescue => e
|
32
|
-
return FieldNotFoundEvaluation.new(key, $page, e.to_s)
|
33
|
-
end
|
17
|
+
field = $page.Get(key)
|
18
|
+
return FieldNotFoundEvaluation.new(key, $page, "selenium could not find the field") if field == nil
|
34
19
|
|
35
|
-
|
36
|
-
return FieldNotFoundEvaluation.new(key, $page, e.to_s)
|
37
|
-
end
|
20
|
+
return Fix(field.Evaluate(key, item, comparator, block), comparator)
|
38
21
|
end
|
39
22
|
|
40
23
|
def Show(item, comparator)
|
@@ -43,49 +43,35 @@ class Symbol
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def Selected(item, comparator)
|
46
|
-
Examine(item, comparator) do |field|
|
46
|
+
Examine(item, comparator) do |field, value|
|
47
47
|
field.Selected
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
def Checked(item, comparator)
|
52
|
-
Examine(item, comparator) do |field|
|
52
|
+
Examine(item, comparator) do |field, value|
|
53
53
|
field.Checked
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
def Show(item, comparator)
|
58
|
-
Examine(item, comparator) do |field|
|
58
|
+
Examine(item, comparator) do |field, value|
|
59
59
|
field.Visible
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
def Examine(key, comparator, &block)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
return Evaluation.new(true, true) if element.nil? and comparator.Compare(true, false)
|
64
|
+
item = key
|
65
|
+
key = item.first if item.is_a? Array
|
68
66
|
return FieldNotDefinedEvaluation.new(key, $page) if !$page.Contains key
|
69
67
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
begin
|
74
|
-
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
75
|
-
result = wait.until {
|
76
|
-
y = comparator.Compare(block.call(field), true)
|
77
|
-
y if y == true
|
78
|
-
}
|
79
|
-
|
68
|
+
field = $page.Get(key)
|
69
|
+
return FieldNotFoundEvaluation.new(key, $page, "selenium could not find the field") if field == nil
|
80
70
|
|
81
|
-
|
82
|
-
|
83
|
-
return FieldNotFoundEvaluation.new(key, $page, e.to_s)
|
84
|
-
end
|
71
|
+
element = field.Find(comparator)
|
72
|
+
return Evaluation.new(true, true) if element.nil? and comparator.Compare(true, false)
|
85
73
|
|
86
|
-
|
87
|
-
return FieldNotFoundEvaluation.new(key, $page, e.to_s)
|
88
|
-
end
|
74
|
+
return Fix(field.Evaluate(key, item, comparator, block), comparator)
|
89
75
|
end
|
90
76
|
|
91
77
|
def Fix(evaluation, comparator)
|
@@ -51,7 +51,7 @@ module Sapphire
|
|
51
51
|
|
52
52
|
def Visible
|
53
53
|
control = self.Find
|
54
|
-
control.displayed
|
54
|
+
Evaluation.new(control.displayed?, true)
|
55
55
|
end
|
56
56
|
|
57
57
|
def Equals(value, comparator)
|
@@ -74,6 +74,45 @@ module Sapphire
|
|
74
74
|
#error land
|
75
75
|
return Evaluation.new(text, values)
|
76
76
|
end
|
77
|
+
|
78
|
+
def Evaluate(key, arg, comparator, block)
|
79
|
+
|
80
|
+
value = GetValue(arg, key)
|
81
|
+
timeout = GetValue(arg, :wait)
|
82
|
+
timeout ||= 5
|
83
|
+
|
84
|
+
begin
|
85
|
+
evaluation = block.call(self, value)
|
86
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => timeout)
|
87
|
+
result = wait.until {
|
88
|
+
evaluation = block.call(self, value)
|
89
|
+
y = evaluation.Evaluate()
|
90
|
+
comparator = EqualsComparison.new(evaluation) if evaluation == nil
|
91
|
+
evaluation if comparator.Compare(y == true, true)
|
92
|
+
}
|
93
|
+
|
94
|
+
return result
|
95
|
+
rescue
|
96
|
+
return Evaluation.new(evaluation.left, evaluation.right)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def GetValue(item, key)
|
101
|
+
|
102
|
+
if item.is_a? Array
|
103
|
+
item.each do |sub_item|
|
104
|
+
value = GetValue(sub_item, key)
|
105
|
+
return value if !value.nil?
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
if item.is_a? Hash
|
110
|
+
return item[key] if item.has_key? key
|
111
|
+
end
|
112
|
+
|
113
|
+
nil
|
114
|
+
end
|
115
|
+
|
77
116
|
end
|
78
117
|
end
|
79
118
|
end
|
@@ -2,7 +2,7 @@ module Sapphire
|
|
2
2
|
module WebAbstractions
|
3
3
|
class CheckBox < Control
|
4
4
|
def Check (value)
|
5
|
-
checked = self.Checked
|
5
|
+
checked = self.Checked().Evaluate()
|
6
6
|
|
7
7
|
if value && checked
|
8
8
|
return;
|
@@ -17,7 +17,7 @@ module Sapphire
|
|
17
17
|
|
18
18
|
def Checked
|
19
19
|
radio = self.Find
|
20
|
-
radio.attribute("checked") != nil
|
20
|
+
Evaluation.new(radio.attribute("checked") != nil, true)
|
21
21
|
end
|
22
22
|
|
23
23
|
def Clear
|
@@ -14,7 +14,14 @@ module Sapphire
|
|
14
14
|
return EqualsComparison.new(Evaluation.new(item.text, value))
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
|
+
#if here then it couldnt make a match, build up the list of values
|
19
|
+
alltext = []
|
20
|
+
x.each do |item|
|
21
|
+
alltext << item.text
|
22
|
+
end
|
23
|
+
|
24
|
+
return EqualsComparison.new(Evaluation.new(alltext, value))
|
18
25
|
end
|
19
26
|
|
20
27
|
def In(values, comparator)
|
@@ -14,13 +14,13 @@ module Sapphire
|
|
14
14
|
def Selected
|
15
15
|
radio = self.Find
|
16
16
|
val = radio.attribute("selected")
|
17
|
-
return val != nil
|
17
|
+
return Evaluation.new(val != nil, true)
|
18
18
|
end
|
19
19
|
|
20
20
|
def Visible
|
21
21
|
radio = self.Find
|
22
22
|
x = radio.attribute("disabled")
|
23
|
-
|
23
|
+
Evaluation.new((x == "false"), true)
|
24
24
|
end
|
25
25
|
|
26
26
|
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.7.
|
4
|
+
version: 0.7.4
|
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-
|
12
|
+
date: 2012-03-01 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|
16
|
-
requirement: &
|
16
|
+
requirement: &9733176 !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: *9733176
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colorize
|
27
|
-
requirement: &
|
27
|
+
requirement: &9732924 !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: *9732924
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: Platform
|
38
|
-
requirement: &
|
38
|
+
requirement: &9732672 !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: *9732672
|
47
47
|
description: An automated web acceptance test framework for non-technical resources
|
48
48
|
using selenium-wedriver.
|
49
49
|
email:
|