sapphire 0.7.16 → 0.7.17
Sign up to get free protection for your applications and to get access to all the features.
@@ -176,34 +176,54 @@ module Sapphire
|
|
176
176
|
end
|
177
177
|
|
178
178
|
def FindItem(array, comparator = nil)
|
179
|
-
masterWait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
180
179
|
|
181
|
-
|
182
|
-
|
183
|
-
array.each do |item|
|
180
|
+
x = nil
|
181
|
+
array.each do |item|
|
184
182
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
183
|
+
if item.is_a? Hash
|
184
|
+
begin
|
185
|
+
x = self.FindElement item.keys.first, item.fetch(item.keys.first)
|
186
|
+
rescue
|
187
|
+
#do nothing, let it keep looping
|
188
|
+
end
|
189
|
+
end
|
192
190
|
|
193
|
-
|
191
|
+
x = self.FindElement item[0], item[1] if item.is_a? Array
|
194
192
|
|
195
|
-
|
196
|
-
|
193
|
+
return x if x != nil
|
194
|
+
return x if comparator.Compare(x != nil, true) if comparator != nil
|
197
195
|
|
198
|
-
|
196
|
+
end if array.is_a? Array
|
199
197
|
|
200
|
-
|
198
|
+
x = self.FindElement array.keys.first, array.fetch(array.keys.first) if array.is_a? Hash
|
199
|
+
return x if x != nil
|
200
|
+
return x if comparator.Compare(x != nil, true) if comparator != nil
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
def FindItemWithWait(array, comparator=nil)
|
205
|
+
masterWait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
206
|
+
|
207
|
+
element = masterWait.until {
|
208
|
+
x = FindItem(array, comparator)
|
201
209
|
return x if x != nil
|
202
210
|
return x if comparator.Compare(x != nil, true) if comparator != nil
|
203
211
|
}
|
212
|
+
|
204
213
|
return element if element != nil
|
205
214
|
return element if comparator.Compare(element != nil, true) if comparator != nil
|
206
215
|
raise "Could not find control for array: " + array.to_s
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
def FindItemWithoutWait(array, comparator=nil)
|
220
|
+
|
221
|
+
element = FindItem(array, comparator)
|
222
|
+
|
223
|
+
return element if element != nil
|
224
|
+
return element if comparator.Compare(element != nil, true) if comparator != nil
|
225
|
+
raise "Could not find control for array: " + array.to_s
|
226
|
+
|
207
227
|
end
|
208
228
|
|
209
229
|
def FindAllItems(array)
|
@@ -239,6 +259,7 @@ module Sapphire
|
|
239
259
|
self.Browser().find_element discriminator, selector
|
240
260
|
end
|
241
261
|
|
262
|
+
|
242
263
|
def FindElements(discriminator, selector)
|
243
264
|
self.Browser().find_elements discriminator, selector
|
244
265
|
end
|
@@ -14,7 +14,7 @@ module Sapphire
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def Browser
|
17
|
-
case($config["Browser"])
|
17
|
+
case(ENV["browser"] || $config["Browser"])
|
18
18
|
when "Firefox" then FireFoxBrowser.new
|
19
19
|
when "Chrome" then ChromeBrowser.new
|
20
20
|
when "IE" then InternetExplorerBrowser.new
|
@@ -22,7 +22,7 @@ module Sapphire
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def ConfiguredBrowser
|
25
|
-
$config["Browser"]
|
25
|
+
ENV["browser"] || $config["Browser"]
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
@@ -6,15 +6,15 @@ module Sapphire
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def Find(comparator = nil)
|
9
|
-
$driver.
|
9
|
+
$driver.FindItemWithWait(@hash, comparator)
|
10
10
|
end
|
11
11
|
|
12
12
|
def FindAll
|
13
13
|
$driver.FindAllItems(@hash)
|
14
14
|
end
|
15
15
|
|
16
|
-
def FindWithoutWait
|
17
|
-
$driver.
|
16
|
+
def FindWithoutWait(comparator = nil)
|
17
|
+
$driver.FindItemWithoutWait(@hash, comparator)
|
18
18
|
end
|
19
19
|
|
20
20
|
def Text
|
@@ -49,8 +49,9 @@ module Sapphire
|
|
49
49
|
sleep(1)
|
50
50
|
end
|
51
51
|
|
52
|
-
def Visible
|
53
|
-
control = self.Find
|
52
|
+
def Visible(shouldWait = true)
|
53
|
+
control = self.Find if shouldWait
|
54
|
+
control = self.FindWithoutWait if !shouldWait
|
54
55
|
Evaluation.new(control.displayed?, true)
|
55
56
|
end
|
56
57
|
|
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.17
|
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-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|
16
|
-
requirement: &
|
16
|
+
requirement: &9864360 !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: *9864360
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colorize
|
27
|
-
requirement: &
|
27
|
+
requirement: &9864108 !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: *9864108
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: Platform
|
38
|
-
requirement: &
|
38
|
+
requirement: &9863856 !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: *9863856
|
47
47
|
description: An automated web acceptance test framework for non-technical resources
|
48
48
|
using selenium-wedriver.
|
49
49
|
email:
|