Class: TestSteps::Handlers::WriteBoxdata

Inherits:
Base
  • Object
show all
Defined in:
lib/functions/handlers/write_box_data.rb

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

Instance Method Details

#perform(step_attributes) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/functions/handlers/write_box_data.rb', line 8

def perform(step_attributes)
  box = step_attributes[:testvalue]
  value = step_attributes[:testvalue2]
  locate = step_attributes[:locate]

  found_box = [
    Browser.b.textarea(:"#{locate}" => box).exist?,
    Browser.b.text_field(:"#{locate}" => box).exist?
  ]
    
  raise 'Multiple matches' if found_box.select { |i| i }.empty?
  index = found_box.index(true)
  return unless index
  if index.zero?
    Browser.b.textarea(:"#{locate}" => box).wait_until.set value
    (Browser.b.textarea(:"#{locate}" => box).value == value)
  elsif index == 1
    Browser.b.text_field(:"#{locate}" => box).wait_until.set value
    (Browser.b.text_field(:"#{locate}" => box).value == value)
  end
  MyLog.log.info("Textbox: #{box} has correct value: #{value}")
  true
rescue StandardError
  MyLog.log.warn("Textbox: #{box} has the incorrect value: #{value}")
  false
rescue StandardError
  MyLog.log.warn("Textbox: #{box} does not exist")
  false
end