Class: TestSteps::Handlers::CheckBoxdata

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

Overview

Check Box Data function.

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



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
37
38
39
40
41
# File 'lib/functions/handlers/check_boxdata.rb', line 11

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(&:exists?)
    (Browser.b.textarea("#{locate}": box).value == value)
  elsif index == 1
    Browser.b.text_field("#{locate}": box).wait_until(&:exists?)
    (Browser.b.text_field("#{locate}": box).value == value)
  end
  MyLog.log.info("Textbox: #{box} has the 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