Class: Sapphire::WebAbstractions::List
- Inherits:
-
Control
show all
- Defined in:
- lib/sapphire/WebAbstractions/Controls/List.rb
Instance Attribute Summary
Attributes inherited from Control
#found_by_type, #found_by_value
Instance Method Summary
collapse
Methods inherited from Control
#Evaluate, #Find, #FindAll, #FindWithoutWait, #GetValue, #MouseOver, #Substitute, #Visible
Constructor Details
#initialize(hash) ⇒ List
Returns a new instance of List.
5
6
7
8
|
# File 'lib/sapphire/WebAbstractions/Controls/List.rb', line 5
def initialize(hash)
@retryAttempts = 0
super hash
end
|
Instance Method Details
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/sapphire/WebAbstractions/Controls/List.rb', line 57
def Click
wait = Selenium::WebDriver::Wait.new(:timeout => 20)
begin
clicked = wait.until { items = self.FindAll
if items.empty? == false
if items.first.Visible == true
items.first.Click
return true
end
end
}
return nil
rescue
if(@retryAttempts < 2)
@retryAttempts = @retryAttempts + 1
self.Click
else
return nil
end
end
end
|
#Contain(value) ⇒ Object
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/sapphire/WebAbstractions/Controls/List.rb', line 46
def Contain(value)
x = self.FindAll
x.each do |item|
if item.Text.include? value
return ContainsComparison.new(ControlEvaluation.new(value, item.Text, item))
end
end
return ControlEvaluation.new("Value not found in list", value, self)
end
|
#Count(value) ⇒ Object
81
82
83
84
|
# File 'lib/sapphire/WebAbstractions/Controls/List.rb', line 81
def Count(value)
items = self.FindAll
return ControlEvaluation.new(items.count, value, self)
end
|
#Equals(value, comparator) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/sapphire/WebAbstractions/Controls/List.rb', line 10
def Equals(value, comparator)
x = self.FindAll
x.each do |item|
if comparator.Compare(item.Text, value)
return EqualsComparison.new(ControlEvaluation.new(item.Text, value, item))
end
end
alltext = []
x.each do |item|
alltext << item.Text
end
return EqualsComparison.new(ControlEvaluation.new(alltext, value, self))
end
|
#In(values, comparator) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/sapphire/WebAbstractions/Controls/List.rb', line 27
def In(values, comparator)
x = self.FindAll
x.each do |item|
values.each do |value|
if comparator.Compare(item.Text, value)
return ControlEvaluation.new(item.Text, value, item)
end
end
end
alltext = []
x.each do |item|
alltext << item.Text
end
return ControlEvaluation.new(values, alltext, self)
end
|
86
87
88
89
90
91
92
93
94
|
# File 'lib/sapphire/WebAbstractions/Controls/List.rb', line 86
def Text
values = []
x = self.FindAll
x.each do |item|
values << item.Text
end
return values
end
|