sapphire 0.7.6 → 0.7.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.
@@ -26,6 +26,14 @@ module Sapphire
26
26
  @item.Evaluate
27
27
  end
28
28
 
29
+ def left=(val)
30
+ @item.left=val
31
+ end
32
+
33
+ def right=(val)
34
+ @item.right=val
35
+ end
36
+
29
37
  def left
30
38
  @item.left
31
39
  end
@@ -2,8 +2,8 @@ module Sapphire
2
2
  module DSL
3
3
  class Evaluation
4
4
 
5
- attr_reader :left
6
- attr_reader :right
5
+ attr_accessor :left
6
+ attr_accessor :right
7
7
 
8
8
  def initialize(left, right)
9
9
  @left = left
@@ -9,15 +9,38 @@ class Hash < Object
9
9
  end
10
10
 
11
11
  def Examine(item, comparator, &block)
12
- key = item.first.keys.first if item.first.is_a? Hash
13
- key = item.first.first if item.first.is_a? Array
14
12
 
15
- return FieldNotDefinedEvaluation.new(key, $page) if !$page.Contains key
13
+ key = GetKey(item) do |item| item.keys.first end
14
+
15
+ return FieldNotDefinedEvaluation.new(key, $page) if !$page.Contains key and !Parameters.instance.Contains key
16
+
17
+ field = $page.Get(key) if $page.Contains key
18
+
19
+ if(field.nil?)
20
+ key1 = GetKey(item) do |item| item[item.keys.first] end
21
+ if $page.Contains key1
22
+ field = $page.Get(key1)
23
+ flip = true
24
+ end
25
+ end
16
26
 
17
- field = $page.Get(key)
18
27
  return FieldNotFoundEvaluation.new(key, $page, "selenium could not find the field") if field == nil
28
+ evaluation = field.Evaluate(key, item, comparator, block)
29
+
30
+ if(flip)
31
+ left = evaluation.left
32
+ right = evaluation.right
33
+
34
+ evaluation.right = left
35
+ evaluation.left = right
36
+ end
37
+
38
+ return Fix(evaluation, comparator)
39
+ end
19
40
 
20
- return Fix(field.Evaluate(key, item, comparator, block), comparator)
41
+ def GetKey(item, &block)
42
+ return block.call(item.first) if item.first.is_a? Hash
43
+ return item.first.first if item.first.is_a? Array
21
44
  end
22
45
 
23
46
  def Show(item, comparator)
@@ -82,6 +82,7 @@ module Sapphire
82
82
  timeout ||= 5
83
83
 
84
84
  begin
85
+ value = value.Text if value.is_a? Control
85
86
  evaluation = block.call(self, value)
86
87
  wait = Selenium::WebDriver::Wait.new(:timeout => timeout)
87
88
  result = wait.until {
@@ -98,6 +99,7 @@ module Sapphire
98
99
  end
99
100
 
100
101
  def GetValue(item, key)
102
+ return Parameter(key) if Parameters.instance.Contains(key)
101
103
 
102
104
  if item.is_a? Array
103
105
  item.each do |sub_item|
@@ -107,12 +109,19 @@ module Sapphire
107
109
  end
108
110
 
109
111
  if item.is_a? Hash
110
- return item[key] if item.has_key? key
112
+ return Substitute(item[key]) if item.has_key? key
111
113
  end
112
114
 
113
115
  nil
114
116
  end
115
117
 
118
+ def Substitute(item)
119
+ return Parameter(item) if Parameters.instance.Contains(item)
120
+ return $page.Get(item) if $page.Contains(item)
121
+
122
+ return item
123
+ end
124
+
116
125
  end
117
126
  end
118
127
  end
@@ -1,3 +1,3 @@
1
1
  module Sapphire
2
- VERSION = "0.7.6"
2
+ VERSION = "0.7.7"
3
3
  end
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.6
4
+ version: 0.7.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-02 00:00:00.000000000Z
12
+ date: 2012-03-09 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: selenium-webdriver