sapphire 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sapphire/DSL/Browser/Create.rb +2 -2
- data/lib/sapphire/DSL/Browser/Verbs/Matrix.rb +41 -0
- data/lib/sapphire/DSL/Browser/Verbs/Using.rb +10 -0
- data/lib/sapphire/Extensions/Hash.rb +22 -0
- data/lib/sapphire/WebAbstractions/Controls/Base/Control.rb +6 -2
- data/lib/sapphire/version.rb +1 -1
- metadata +10 -8
@@ -0,0 +1,41 @@
|
|
1
|
+
module Sapphire
|
2
|
+
module DSL
|
3
|
+
module Browser
|
4
|
+
|
5
|
+
def Matrix(symbol)
|
6
|
+
return Matrix.new(symbol)
|
7
|
+
end
|
8
|
+
|
9
|
+
class Matrix
|
10
|
+
|
11
|
+
attr_reader :id
|
12
|
+
|
13
|
+
def initialize(id)
|
14
|
+
@id = id
|
15
|
+
end
|
16
|
+
|
17
|
+
def Create(matrix, &block)
|
18
|
+
$matrix_variable = matrix.id
|
19
|
+
block.call
|
20
|
+
$matrix_variable = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def Using(matrix, &block)
|
24
|
+
raise "No matrix defined for: " + matrix.id if !$matrices.has_key? matrix.id
|
25
|
+
|
26
|
+
$matrices[matrix.id].each do |array|
|
27
|
+
array.each do |item|
|
28
|
+
item.call()
|
29
|
+
end
|
30
|
+
block.call()
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
@@ -10,6 +10,7 @@ class Hash < Object
|
|
10
10
|
|
11
11
|
def Examine(item, comparator, &block)
|
12
12
|
|
13
|
+
flip = false
|
13
14
|
key = GetKey(item) do |item| item.keys.first end
|
14
15
|
|
15
16
|
return FieldNotDefinedEvaluation.new(key, $page) if !$page.Contains key and !Parameters.instance.Contains key
|
@@ -24,6 +25,8 @@ class Hash < Object
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
28
|
+
return Fix(Evaluation.new(Parameter(key), item.first[key]), comparator) if Parameters.instance.Contains(key) and field.nil?
|
29
|
+
|
27
30
|
return FieldNotFoundEvaluation.new(key, $page, "selenium could not find the field") if field == nil
|
28
31
|
evaluation = field.Evaluate(key, item, comparator, block)
|
29
32
|
|
@@ -35,6 +38,7 @@ class Hash < Object
|
|
35
38
|
evaluation.left = right
|
36
39
|
end
|
37
40
|
|
41
|
+
|
38
42
|
return Fix(evaluation, comparator)
|
39
43
|
end
|
40
44
|
|
@@ -88,4 +92,22 @@ class Hash < Object
|
|
88
92
|
comparator = comparator.Create(evaluation)
|
89
93
|
comparator
|
90
94
|
end
|
95
|
+
|
96
|
+
def Using(items)
|
97
|
+
$matrices ||= {}
|
98
|
+
|
99
|
+
master_array = []
|
100
|
+
master_array = $matrices[$matrix_variable] if $matrices.has_key? $matrix_variable
|
101
|
+
|
102
|
+
array = []
|
103
|
+
|
104
|
+
items.keys.each do |key|
|
105
|
+
array << Proc.new { Parameter key => items[key] }
|
106
|
+
end
|
107
|
+
|
108
|
+
master_array << array
|
109
|
+
|
110
|
+
$matrices.merge! $matrix_variable => master_array
|
111
|
+
end
|
112
|
+
|
91
113
|
end
|
@@ -84,6 +84,7 @@ module Sapphire
|
|
84
84
|
begin
|
85
85
|
value = value.Text if value.is_a? Control
|
86
86
|
evaluation = block.call(self, value)
|
87
|
+
|
87
88
|
wait = Selenium::WebDriver::Wait.new(:timeout => timeout)
|
88
89
|
result = wait.until {
|
89
90
|
evaluation = block.call(self, value)
|
@@ -99,7 +100,6 @@ module Sapphire
|
|
99
100
|
end
|
100
101
|
|
101
102
|
def GetValue(item, key)
|
102
|
-
return Parameter(key) if Parameters.instance.Contains(key)
|
103
103
|
|
104
104
|
if item.is_a? Array
|
105
105
|
item.each do |sub_item|
|
@@ -109,15 +109,19 @@ module Sapphire
|
|
109
109
|
end
|
110
110
|
|
111
111
|
if item.is_a? Hash
|
112
|
+
return Substitute(key) if Parameters.instance.Contains(key)
|
112
113
|
return Substitute(item[key]) if item.has_key? key
|
113
114
|
end
|
114
115
|
|
116
|
+
return Parameter(key) if Parameters.instance.Contains(key)
|
117
|
+
|
115
118
|
nil
|
116
119
|
end
|
117
120
|
|
118
121
|
def Substitute(item)
|
119
|
-
|
122
|
+
|
120
123
|
return $page.Get(item) if $page.Contains(item)
|
124
|
+
return Parameter(item) if Parameters.instance.Contains(item)
|
121
125
|
|
122
126
|
return item
|
123
127
|
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.8
|
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-13 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|
16
|
-
requirement: &
|
16
|
+
requirement: &9870684 !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: *9870684
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colorize
|
27
|
-
requirement: &
|
27
|
+
requirement: &9870432 !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: *9870432
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: Platform
|
38
|
-
requirement: &
|
38
|
+
requirement: &9870180 !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: *9870180
|
47
47
|
description: An automated web acceptance test framework for non-technical resources
|
48
48
|
using selenium-wedriver.
|
49
49
|
email:
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/sapphire/DSL/Browser/Verbs/Exists.rb
|
89
89
|
- lib/sapphire/DSL/Browser/Verbs/Exit.rb
|
90
90
|
- lib/sapphire/DSL/Browser/Verbs/Has.rb
|
91
|
+
- lib/sapphire/DSL/Browser/Verbs/Matrix.rb
|
91
92
|
- lib/sapphire/DSL/Browser/Verbs/MouseOver.rb
|
92
93
|
- lib/sapphire/DSL/Browser/Verbs/Navigate.rb
|
93
94
|
- lib/sapphire/DSL/Browser/Verbs/On.rb
|
@@ -98,6 +99,7 @@ files:
|
|
98
99
|
- lib/sapphire/DSL/Browser/Verbs/Start.rb
|
99
100
|
- lib/sapphire/DSL/Browser/Verbs/Switch.rb
|
100
101
|
- lib/sapphire/DSL/Browser/Verbs/Uncheck.rb
|
102
|
+
- lib/sapphire/DSL/Browser/Verbs/Using.rb
|
101
103
|
- lib/sapphire/DSL/Browser/Verbs/Virtually.rb
|
102
104
|
- lib/sapphire/DSL/Browser/Verbs/Wait.rb
|
103
105
|
- lib/sapphire/DSL/Comparisons/CheckedComparison.rb
|