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.find_element(id: user_elm).displayed?
    Taf::Browser.b.find_element(id: user_elm).send_keys user
    Taf::Browser.b.find_element(id: pass_elm).send_keys pass
    Taf::Browser.b.find_element(name: 'commit').click
    sleep 1
  else
    Taf::MyLog.log.warn("User: #{user} has failed to log in.")
  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.current_url == url
    Taf::MyLog.log.info("URL: #{url} is correct.")
    true
  else
    Taf::MyLog.log.warn("URL: #{url} is incorrect.")
    false
  end
end