Class: Taf::TestSteps::Handlers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/taf/test_steps/handlers/base.rb

Overview

All Login functions function.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step_attributes) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
# File 'lib/taf/test_steps/handlers/base.rb', line 9

def initialize(step_attributes)
  @value =  step_attributes[:testvalue]
  @value2 = step_attributes[:testvalue2]
  @locate = step_attributes[:locate]
end

Class Method Details

.perform(*args) ⇒ Object



19
20
21
# File 'lib/taf/test_steps/handlers/base.rb', line 19

def self.perform(*args)
  new(*args).perform
end

.register(name) ⇒ Object



15
16
17
# File 'lib/taf/test_steps/handlers/base.rb', line 15

def self.register(name)
  TestSteps.handlers[name.to_s] = self
end

Instance Method Details

#login_check(b_title_success, user) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/taf/test_steps/handlers/base.rb', line 45

def (b_title_success, user)
  if Taf::Browser.b.title.eql?(b_title_success)
    Taf::MyLog.log.info("User: #{user} has logged in successful.")
    true
  else
    Taf::MyLog.log.warn("User: #{user} has failed to log in.")
    false
  end
end

#login_process(b_title, user_elm, pass_elm, user, pass) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/taf/test_steps/handlers/base.rb', line 23

def (b_title, user_elm, pass_elm, user, pass)
  if Taf::Browser.b.title.eql?(b_title)
    Taf::Browser.b.text_field(id: user_elm).wait_until(&:exists?)
                .set user
    Taf::Browser.b.text_field(id: pass_elm).set pass
    Taf::Browser.b.button(value: 'Sign in').wait_until(&:exists?).click
    sleep 1
  else
    Taf::MyLog.log.warn("User: #{user} has failed to log in.")
  end
end

#portal_mem_word(user, b_title_success) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/taf/test_steps/handlers/base.rb', line 55

def portal_mem_word(user, b_title_success)
  password = ENV['PORTAL_MEM']
  nums = (1..256).to_a
  found_mem_nums = nums.each_with_object([]) do |num_val, mem_word|
    elm_id = "user_memorable_parts_#{num_val}"
    mem_word.push(num_val) if Taf::Browser.b.select(id: elm_id).exist?
  end.compact

  array_password = password.split('')
  array_password.map!(&:upcase)

  found_mem_nums.each do |mem_num|
    char = array_password[(mem_num - 1)]
    elm_id = "user_memorable_parts_#{mem_num}"
    Taf::Browser.b.select_list(id: elm_id).option(value: char.to_s)
                .select
  end

  Taf::Browser.b.button(value: 'Sign in').wait_until(&:exists?).click
  if Taf::Browser.b.title.eql?(b_title_success)
    Taf::MyLog.log.info("User: #{user} has logged in successful.")
    return true
  else
    Taf::MyLog.log.warn("User: #{user} has failed to log in.")
    return false
  end
end

#url_check(url) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/taf/test_steps/handlers/base.rb', line 35

def url_check(url)
  if Taf::Browser.b.url == url
    Taf::MyLog.log.info("URL: #{url} is correct.")
    true
  else
    Taf::MyLog.log.warn("URL: #{url} is incorrect.")
    false
  end
end