Class: LdsBlock
- Inherits:
-
Object
show all
- Defined in:
- lib/TNR360/components/lds_block.rb
Instance Method Summary
collapse
Constructor Details
#initialize(browser, idBlock, idScreen = nil) ⇒ LdsBlock
26
27
28
29
30
31
32
|
# File 'lib/TNR360/components/lds_block.rb', line 26
def initialize(browser, idBlock, idScreen=nil)
@browser =browser
@idBlock=idBlock
@idScreen=idScreen
update
@exists
end
|
Instance Method Details
#collapse ⇒ Object
205
206
207
208
209
210
|
# File 'lib/TNR360/components/lds_block.rb', line 205
def collapse
if (@collapsible && !@collapsed)
@current_element.div(:index => 0).div(:index => 0).div.when_present.click
end
update
end
|
#elementExists?(idElement) ⇒ Boolean
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# File 'lib/TNR360/components/lds_block.rb', line 139
def elementExists?(idElement)
oneIsVisible=false
if (!@browser.div(:id => idElement).exists?)
@browser.div(:id => idElement).when_present(10)
oneIsVisible=true
else
if (!@browser.div(:id => idElement).visible?)
@browser.divs(:id => idElement).each do |field|
if field.visible?
oneIsVisible=true
break
end
end
if !oneIsVisible
@browser.div(:id => idElement).when_present(10)
oneIsVisible=true
end
else
oneIsVisible=true
end
end
oneIsVisible
end
|
#expand ⇒ Object
212
213
214
215
216
217
|
# File 'lib/TNR360/components/lds_block.rb', line 212
def expand
if (@collapsible && @collapsed)
@current_element.div(:index => 0).div(:index => 0).div.when_present.click
end
update
end
|
76
77
78
79
80
81
82
83
84
|
# File 'lib/TNR360/components/lds_block.rb', line 76
def
if (@hasMultipleAreas)
@areas=Array.new
@current_element.fieldsets.each do |fieldset|
@areas << LdsArea.new(@browser, fieldset.id.to_s, self)
end
end
end
|
#findElement(idElement) ⇒ Object
method locate current element
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/TNR360/components/lds_block.rb', line 104
def findElement idElement
@current_element=nil
proc=Proc.new { isScreenDisplayed }
force_find_element(proc).to_s
proc=Proc.new { elementExists?(idElement) }
@exists=force_find_element(proc)
puts 'Block found = '+@exists.to_s
if (@browser.divs(:id => idElement).length>1)
@browser.divs(:id => idElement).each do |field|
if field.visible?
@current_element=field
break
end
end
else
@current_element=@browser.div(:id => idElement).when_present
end
if @current_element.visible?
puts 'block is visible'
else
puts 'block is NOT visible'
end
@current_element
end
|
#getAreas ⇒ Object
237
238
239
|
# File 'lib/TNR360/components/lds_block.rb', line 237
def getAreas
@areas
end
|
#getElement ⇒ Object
221
222
223
|
# File 'lib/TNR360/components/lds_block.rb', line 221
def getElement
@current_element
end
|
#getIdBlock ⇒ Object
225
226
227
|
# File 'lib/TNR360/components/lds_block.rb', line 225
def getIdBlock
@idBlock
end
|
#getIdScreen ⇒ Object
229
230
231
|
# File 'lib/TNR360/components/lds_block.rb', line 229
def getIdScreen
@idScreen
end
|
#getTitle ⇒ Object
233
234
235
|
# File 'lib/TNR360/components/lds_block.rb', line 233
def getTitle
@title
end
|
#getType ⇒ Object
241
242
243
|
# File 'lib/TNR360/components/lds_block.rb', line 241
def getType
@type
end
|
#hasMultipleAreas? ⇒ Boolean
245
246
247
|
# File 'lib/TNR360/components/lds_block.rb', line 245
def hasMultipleAreas?
@hasMultipleAreas
end
|
#isCollapsed? ⇒ Boolean
253
254
255
|
# File 'lib/TNR360/components/lds_block.rb', line 253
def isCollapsed?
@collapsed
end
|
#isCollapsible? ⇒ Boolean
249
250
251
|
# File 'lib/TNR360/components/lds_block.rb', line 249
def isCollapsible?
@collapsible
end
|
#isExist? ⇒ Boolean
261
262
263
|
# File 'lib/TNR360/components/lds_block.rb', line 261
def isExist?
@exists
end
|
#isScreenDisplayed ⇒ Object
165
166
167
168
169
170
171
172
|
# File 'lib/TNR360/components/lds_block.rb', line 165
def isScreenDisplayed
if (@idScreen!=nil)
@scr=LdsScreen.new(@browser, @idScreen)
@scr.isVisible?
else
false
end
end
|
#isVisible? ⇒ Boolean
257
258
259
|
# File 'lib/TNR360/components/lds_block.rb', line 257
def isVisible?
@visible
end
|
#refresh ⇒ Object
refresh object status from browser
36
37
38
39
40
41
42
|
# File 'lib/TNR360/components/lds_block.rb', line 36
def refresh
@current_element= findElement @idBlock
update
@exists
end
|
#reverse_collapse ⇒ Object
198
199
200
201
202
203
|
# File 'lib/TNR360/components/lds_block.rb', line 198
def reverse_collapse
if (@collapsible)
@current_element.div(:index => 0).div(:index => 0).div.when_present.click
end
update
end
|
#to_s ⇒ Object
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
# File 'lib/TNR360/components/lds_block.rb', line 176
def to_s
if (@hasMultipleAreas && @areas!=nil)
@areas.each do |area|
area.to_s
end
else
"\n***** Block *****"+
"\nIdBlock : "+ no_null(@idBlock)+
"\nIdScreen : "+ no_null(@idScreen) +
"\nTitle : "+ no_null(@title)+
"\nCollapsible :"+ bool_no_null(@collapsible.to_s)+
"\nCollapsed :"+ bool_no_null(@collapsed.to_s)+
"\nVisible : "+ bool_no_null(@visible.to_s)+
"\nExists : "+ bool_no_null(@exists.to_s)+
"\nHasMultipleAreas :"+ bool_no_null(@hasMultipleAreas.to_s)+
"\nType :"+ no_null(@type.to_s)+
"\n**********"
end
end
|