Class: TestSteps::Handlers::WriteBoxdata
- Inherits:
-
Base
- Object
- Base
- TestSteps::Handlers::WriteBoxdata
show all
- Defined in:
- lib/functions/handlers/write_box_data.rb
Overview
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#login_button, #login_check, #login_process, #mem_word_check, #open_url_process, perform, #portal_mem_word, register
Class Method Details
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/functions/handlers/write_box_data.rb', line 20
def self.input_value(box, txt, locate)
found_box = [
Browser.b.textarea("#{locate}": box).exist?,
Browser.b.text_field("#{locate}": box).exist?,
Browser.b.iframe("#{locate}": box).exist?
]
raise 'Multiple matches' if found_box.select { |i| i }.empty?
index = found_box.index(true)
return unless index
WriteBoxdata.write_to_box_data(index, box, txt, locate)
end
|
.write_to_box_data(index, box, txt, locate) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/functions/handlers/write_box_data.rb', line 35
def self.write_to_box_data(index, box, txt, locate)
if index.zero?
Browser.b.textarea("#{locate}": box).wait_until(&:exists?).set txt
(Browser.b.textarea("#{locate}": box).text == txt)
elsif index == 1
Browser.b.text_field("#{locate}": box).wait_until(&:exists?).set txt
(Browser.b.text_field("#{locate}": box).text == txt)
elsif index == 2
Browser.b.iframe("#{locate}": box).wait_until(&:exists?).send_keys txt
end
MyLog.log.info("Textbox: #{box} has correct value: #{txt}")
true
rescue StandardError
MyLog.log.warn("Textbox: #{box} has the incorrect value: #{txt}")
false
rescue StandardError
MyLog.log.warn("Textbox: #{box} does not exist")
false
end
|
Instance Method Details
11
12
13
14
15
16
17
18
|
# File 'lib/functions/handlers/write_box_data.rb', line 11
def perform(step_attributes)
box = step_attributes[:testvalue]
value = step_attributes[:testvalue2]
locate = step_attributes[:locate]
txt = ENV[value.to_s] || step_attributes[:testvalue2]
WriteBoxdata.input_value(box, txt, locate)
end
|