Top Level Namespace

Includes:
RbConfig

Defined Under Namespace

Modules: Ifd Classes: IFD_Assertion

Instance Method Summary collapse

Instance Method Details

#call_step(str_step) ⇒ Object



3
4
5
6
# File 'lib/Ifd_Mobile/methods/core.rb', line 3

def call_step str_step
  put_log "\n-=> call step: #{str_step}"
  step %{#{str_step}}
end

#click_by_coordinate(x, y) ⇒ Object



134
135
136
# File 'lib/Ifd_Mobile/methods/core.rb', line 134

def click_by_coordinate x, y
  selenium.execute_script 'mobile: tap', :x => x, :y => y
end

#execute_checkproperty(element, property, negate, value) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/Ifd_Mobile/methods/core.rb', line 92

def execute_checkproperty element, property, negate, value
  found_element = find_object element
  check = false
  if found_element == nil and value == ""
    check = true
    expect(check).to eq true
  else
    put_log "\n*** Execute_CheckProperty: finish to found element"
    if found_element != nil
      if property.upcase == 'VALUE'
        actual_value = found_element.attribute("value")
      elsif property.upcase == 'NAME'
        actual_value = found_element.attribute("name")
      elsif property.upcase == 'LABEL'
        actual_value = found_element.attribute("label")
      elsif property.upcase == 'TYPE'
        actual_value = found_element.attribute("type")
      elsif property.upcase == 'ENABLE'
        actual_value = found_element.attribute("enable")
      else
        actual_value = found_element.attribute("#{property}")
      end
      if actual_value == nil
        actual_value = ''
      end
    else
      put_log "ERROR: *** Not found object: #{element}"
    end

    if IFD_Assertion.reg_compare(actual_value, value)
      check = true
    end

    put_log "\n#{property} :: Actual Result Is '#{actual_value}' -- Expected Result Is '#{value}'"

    if negate == " not"
      expect(check).not_to eql true
    elsif expect(check).to eq true
    end
  end
end

#execute_click(element) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/Ifd_Mobile/methods/core.rb', line 61

def execute_click element
  found_element = find_object element
  if found_element != nil
    startTime = Time.new.to_i
    begin
      sleep(1)
      currentTime= Time.new.to_i
    end while (currentTime - startTime) < $_CONFIG['Wait Time']
    # selenium.execute_script('mobile: scroll', found_element)
    found_element.click
  else
    put_log "\nERROR: *** not found object: #{element}"
  end
end

#execute_settext(element, text) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/Ifd_Mobile/methods/core.rb', line 76

def execute_settext element, text
  found_element = find_object element
  if found_element != nil
    begin
      sleep(1)
      # found_element.long_press_keycode(46)
      found_element.send_keys(text)
    rescue StandardError => myStandardError
      put_log "\nERROR: *** #{myStandardError}"
    end
  else
    put_log "\nERROR: *** not found object: #{element}"
    exit
  end
end

#find_object(string_object) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/Ifd_Mobile/methods/core.rb', line 12

def find_object string_object
  # startTime = Time.new.to_i
  string_object = string_object.gsub(/"/, "'")
  # puts string_object
  locator_matching = /(.*?)(\{.*?\})/.match(string_object)
  # puts "locator_matching : #{locator_matching}"
  dyn_pros = {}
  if locator_matching != nil
    string_object = locator_matching[1]
    eval(locator_matching[2].gsub(/['][\s,\t]*?:[\s,\t]*?[']?/, "'=>'")).each { |k, v|
      dyn_pros[k.to_s.upcase] = v
    }
  end
  hash_object = $_RP_OBJECT[string_object]
  puts hash_object
  if hash_object == nil
    put_log ">>> OBJECT NAME MAYBE NOT FOUND!!!"
    true.should eq false
  end
  attribute = {}
  if hash_object != nil
    hash_object.each { |k, v|
      k = k.to_s
      if k =~ /ph_/i
        if dyn_pros[k] != nil
          # Assign place holder value to place holder property, also remove prefix ph_ from property key,
          # also remove this pl from dyn_pros <= should be consider to continue transfer into inner object in relation
          if v =~ /<ph_value>/i
            attribute[k[3..k.size-1]] = v.gsub(/<ph_value>/i, dyn_pros[k])
          else
            attribute[k[3..k.size-1]] = dyn_pros[k]
          end
          dyn_pros.delete(k)
        end
      else
        attribute[k.to_s] = v
      end
    }
  end
  # put_log string_object
  # put_log "\nattribute: #{attribute}"

  attribute.each { |key, value|
    $element_tag = key
    $element_value = value
  }
  return selenium.find_element($element_tag, $element_value)
end

#put_log(str) ⇒ Object



8
9
10
# File 'lib/Ifd_Mobile/methods/core.rb', line 8

def put_log str
  puts str if $_CONFIG['Print Log'] == true
end

#replace_day(str) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/Ifd_Mobile/methods/lib_var.rb', line 37

def replace_day str
  t = Time.now()
  _day = t.day
  if _day < 10
    return str.gsub("{day}", "0#{_day.to_s}")
  else
    return str.gsub("{day}", "#{_day.to_s}")
  end
  return str
end

#replace_month(str) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/Ifd_Mobile/methods/lib_var.rb', line 26

def replace_month str
  t = Time.now()
  _month = t.month
  if _month < 10
    return str.gsub("{month}", "0#{_month.to_s}")
  else
    return str.gsub("{month}", "#{_month.to_s}")
  end
  return str
end

#replace_pipe(str_pipe) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/Ifd_Mobile/methods/lib_var.rb', line 48

def replace_pipe str_pipe
  put_log ">>>> #{str_pipe}"
  if str_pipe =~ /^.*{pipe}.*$/
    return str_pipe.gsub("{pipe}", "|")
  end
  return str_pipe
end

#replace_year(str) ⇒ Object



21
22
23
24
# File 'lib/Ifd_Mobile/methods/lib_var.rb', line 21

def replace_year str
  t = Time.now()
  return str.gsub("{year}", t.year.to_s)
end

#var_collect(string_var) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/Ifd_Mobile/methods/lib_var.rb', line 1

def var_collect string_var
  if string_var =~ /^.*{year}.*$/
    string_var = replace_year(string_var)
  end

  if string_var =~ /^.*{month}.*$/
    string_var = replace_month(string_var)
  end

  if string_var =~ /^.*{day}.*$/
    string_var = replace_day(string_var)
  end

  if string_var =~ /^.*{store_value}.*$/
    string_var = $context_value
  end

  return string_var
end