class Bucky::TestEquipment::Verifications::E2eVerification

Public Class Methods

new(driver, pages, test_case_name) click to toggle source
# File lib/bucky/test_equipment/verifications/e2e_verification.rb, line 16
def initialize(driver, pages, test_case_name)
  @driver = driver
  @pages = pages
  @evidence = Bucky::TestEquipment::Evidence::E2eEvidence.new(driver: driver, test_case: test_case_name)
end

Public Instance Methods

assert_contained_attribute(**args) click to toggle source

Check whether attribute of web element contains excepted value. @param [Hash]

# File lib/bucky/test_equipment/verifications/e2e_verification.rb, line 58
def assert_contained_attribute(**args)
  Bucky::Utils::BuckyLogger.write('assert_contained_attribute', args)
  part = @pages.get_part(args)
  verify_rescue { assert(part[args[:attribute]].include?(args[:expect]&.to_s), "Not Contain Expected Attribute.\nexpect: #{args[:expect].to_s.bg_green.black}\nactual: #{part[args[:attribute]].to_s.bg_red.black}") }
end
assert_contained_text(**args) click to toggle source

Check whether text of web element contains expected value @param [Hash]

# File lib/bucky/test_equipment/verifications/e2e_verification.rb, line 43
def assert_contained_text(**args)
  Bucky::Utils::BuckyLogger.write('assert_contained_text', args)
  part = @pages.get_part(args)
  verify_rescue { assert(part.text.include?(args[:expect]&.to_s), "Not Contain Expected Text.\nexpect: #{args[:expect].to_s.bg_green.black}\nactual: #{part.text.to_s.bg_red.black}") }
end
assert_contained_url(**args) click to toggle source

Check whether url contains excepted value @param [Hash]

# File lib/bucky/test_equipment/verifications/e2e_verification.rb, line 51
def assert_contained_url(**args)
  Bucky::Utils::BuckyLogger.write('assert_contained_url', args)
  verify_rescue { assert(@driver.current_url.include?(args[:expect]&.to_s), "Not Contain Expected URL.\nexpect:  #{args[:expect].to_s.bg_green.black}\nactual: #{@driver.current_url.to_s.bg_red.black}") }
end
assert_display(**args) click to toggle source

Check whether style property includes display:block @param [Hash]

# File lib/bucky/test_equipment/verifications/e2e_verification.rb, line 74
def assert_display(**args)
  Bucky::Utils::BuckyLogger.write('assert display', args)
  verify_rescue { assert_true(@pages.get_part(args).displayed?, "No display this parts.\nURL: #{@driver.current_url}\npage: #{args[:page]}\npart: #{args[:part]}") }
end
assert_exist_part(**args) click to toggle source

Check whether web element exists @param [Hash]

# File lib/bucky/test_equipment/verifications/e2e_verification.rb, line 81
def assert_exist_part(**args)
  Bucky::Utils::BuckyLogger.write('assert_exist_part', args)
  verify_rescue { assert_true(@pages.part_exist?(args), "This part is not exist.\nURL: #{@driver.current_url}\npage: #{args[:page]}\npart: #{args[:part]}") }
end
assert_is_number(**args) click to toggle source

Check whether text of part is number @param [Hash]

# File lib/bucky/test_equipment/verifications/e2e_verification.rb, line 66
def assert_is_number(**args)
  Bucky::Utils::BuckyLogger.write('assert is number', args)
  text = @pages.get_part(args).text.sub(',', '')
  verify_rescue { assert(text.to_i.to_s == text.to_s, "Not number.\nactual: #{text.bg_red.black}") }
end
assert_not_exist_part(**args) click to toggle source

Check whether web element don't exist @param [Hash]

# File lib/bucky/test_equipment/verifications/e2e_verification.rb, line 88
def assert_not_exist_part(**args)
  Bucky::Utils::BuckyLogger.write('assert_not_exist_part', args)
  verify_rescue { assert_false(@pages.part_exist?(args), "This part is exist.\nURL: #{@driver.current_url}\npage: #{args[:page]}\npart: #{args[:part]}") }
end
assert_text(**args) click to toggle source

Check whether text of web element matches expected value @param [Hash]

# File lib/bucky/test_equipment/verifications/e2e_verification.rb, line 35
def assert_text(**args)
  Bucky::Utils::BuckyLogger.write('assert_text', args)
  part = @pages.get_part(args)
  verify_rescue { assert_equal(args[:expect]&.to_s, part.text, 'Not Expected Text.') }
end
assert_title(**args) click to toggle source

Check whether title of web page matches expected value @param [Hash]

# File lib/bucky/test_equipment/verifications/e2e_verification.rb, line 28
def assert_title(**args)
  Bucky::Utils::BuckyLogger.write('assert_title', args)
  verify_rescue { assert_equal(args[:expect]&.to_s, @driver.title, 'Not Expected Title.') }
end
pages_getter() click to toggle source
# File lib/bucky/test_equipment/verifications/e2e_verification.rb, line 22
def pages_getter
  @pages
end

Private Instance Methods

verify_rescue() { || ... } click to toggle source

Common exception method @param [Method] &assert

# File lib/bucky/test_equipment/verifications/e2e_verification.rb, line 97
def verify_rescue
  yield
rescue StandardError => e
  @evidence.save_evidence(e)
  raise e
end