class Bucky::TestEquipment::UserOperation::UserOperator

Public Class Methods

new(args) click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operator.rb, line 13
def initialize(args)
  @operation_helper = Bucky::TestEquipment::UserOperation::UserOperationHelper.new(args)
  @pages = args[:pages]
end

Public Instance Methods

method_missing(operation, test_case_name, **args) click to toggle source

Call user operation by argument @param [String] operation @param [String] test_case_name @param [Hash] args

# File lib/bucky/test_equipment/user_operation/user_operator.rb, line 22
def method_missing(operation, test_case_name, **args)
  @operation = operation
  @test_case_name = test_case_name
  Bucky::Utils::BuckyLogger.write(test_case_name, args[:exec])

  # Call method of UserOperationHelper
  return @operation_helper.send(@operation, args[:exec]) if @operation_helper.methods.include?(@operation)

  # Call method of page object
  # e.g) {page: 'top', operation: 'input_freeword', word: 'testing word'}
  return page_method(args[:exec]) if args[:exec].key?(:page) && !args[:exec].key?(:part)

  # Call method of part
  part_mothod(args[:exec]) if args[:exec].key?(:part)
rescue StandardError => e
  Bucky::Core::Exception::WebdriverException.handle(e, "#{args[:step_number]}:#{args[:proc_name]}")
end

Private Instance Methods

page_method(args) click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operator.rb, line 42
def page_method(args)
  @pages.send(args[:page]).send(@operation, args)
end
part_mothod(args) click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operator.rb, line 46
def part_mothod(args)
  # Multiple parts is saved as hash
  # e.g){page: 'top', part: {locate: 'rosen_tokyo', num: 1}, operate: 'click'}
  if args[:part].class == Hash
    part_name = args[:part][:locate]
    num = args[:part][:num]
    @pages.send(args[:page]).send(part_name)[num].send(@operation)
  # e.g.){page: 'top', part: 'rosen_tokyo', operate: 'click'}
  else
    @pages.send(args[:page]).send(args[:part]).send(@operation)
  end
end