Class: TestSteps::Handlers::Base
- Inherits:
-
Object
- Object
- TestSteps::Handlers::Base
show all
- Defined in:
- lib/functions/handlers/base_handler.rb
Overview
All Login functions function.
Direct Known Subclasses
BrowserBack, BrowserForward, BrowserQuit, BrowserRefresh, CaptureAlert, CheckBox, CheckBoxdata, CheckLogs, CheckScreendata, CheckTitle, CheckUrl, ClickButton, ExecuteSystemCommand, HandleBrowserWindow, Ipause, ListAllDropdownValues, Login, OpenUrl, PingTest, RadioButton, SelectDropdown, SendSpecialKeys, WriteBoxdata
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
14
|
# File 'lib/functions/handlers/base_handler.rb', line 9
def initialize(step_attributes)
@value = step_attributes[:testvalue]
@value2 = step_attributes[:testvalue2]
@locate = step_attributes[:locate]
@locate2 = step_attributes[:locate2]
end
|
Class Method Details
20
21
22
|
# File 'lib/functions/handlers/base_handler.rb', line 20
def self.perform(*args)
new(*args).perform
end
|
.register(name) ⇒ Object
16
17
18
|
# File 'lib/functions/handlers/base_handler.rb', line 16
def self.register(name)
TestSteps.handlers[name.to_s] = self
end
|
Instance Method Details
#login_check(b_title_sucess, user) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/functions/handlers/base_handler.rb', line 41
def login_check(b_title_sucess, user)
if Browser.b.title.eql?(b_title_sucess)
MyLog.log.info("User: #{user} has logged in successful.")
true
else
MyLog.log.warn("User: #{user} has failed to log in.")
false
end
end
|
#login_process(b_title, user_elm, pass_elm, user, pass) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/functions/handlers/base_handler.rb', line 29
def login_process(b_title, user_elm, pass_elm, user, pass)
if Browser.b.title.eql?(b_title)
Browser.b.text_field(id: user_elm).wait_until(&:exists?).set user
Browser.b.text_field(id: pass_elm).wait_until(&:exists?).set pass
button = 'Sign in' || 'Log in'
Browser.b.button(value: button).wait_until(&:exists?).click
sleep 1
else
MyLog.log.warn("User: #{user} has failed to log in.")
end
end
|
#mem_word_check(user, b_title_sucess) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/functions/handlers/base_handler.rb', line 51
def mem_word_check(user, b_title_sucess)
if Browser.b.title.eql?('Memorable word')
portal_mem_word(user, b_title_sucess)
elsif Browser.b.title.eql?(b_title_sucess)
MyLog.log.info("User: #{user} has logged in successful.")
true
else
MyLog.log.warn("User: #{user} has failed to log in.")
false
end
end
|
#open_url_process(url) ⇒ Object
24
25
26
27
|
# File 'lib/functions/handlers/base_handler.rb', line 24
def open_url_process(url)
Browser.open_browser
Browser.b.goto(url)
end
|
#portal_mem_word(user, b_title_sucess) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/functions/handlers/base_handler.rb', line 63
def portal_mem_word(user, b_title_sucess)
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 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}"
Browser.b.select_list(id: elm_id).option(value: char.to_s).select
end
Browser.b.button(value: 'Sign in').wait_until(&:exists?).click
if Browser.b.title.eql?(b_title_sucess)
MyLog.log.info("User: #{user} has logged in successful.")
return true
else
MyLog.log.warn("User: #{user} has failed to log in.")
return false
end
end
|