Ifd_Automation 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/Ifd_Automation +30 -0
- data/bin/generate.rb +20 -0
- data/bin/helper.rb +51 -0
- data/features/TestData/testdata.yml +4 -0
- data/features/TestSuite/Login/login.feature +6 -0
- data/features/step_definitions/lib_steps/login_steps.rb +3 -0
- data/features/step_definitions/repositories/ob_login.rb +3 -0
- data/features/support/env.rb +102 -0
- data/features/support/hooks.rb +57 -0
- data/features/support/project_env.rb +51 -0
- data/lib/Ifd_Automation/assertion_steps.rb +96 -0
- data/lib/Ifd_Automation/email_steps.rb +91 -0
- data/lib/Ifd_Automation/javascript_handling_steps.rb +34 -0
- data/lib/Ifd_Automation/lib_file_steps.rb +45 -0
- data/lib/Ifd_Automation/lib_schema_data_steps.rb +110 -0
- data/lib/Ifd_Automation/lib_web_steps.rb +184 -0
- data/lib/Ifd_Automation/lib_webservice_steps.rb +44 -0
- data/lib/Ifd_Automation/methods/IFD_Assertion_methods.rb +206 -0
- data/lib/Ifd_Automation/methods/IFD_Connection.rb +28 -0
- data/lib/Ifd_Automation/methods/IFD_email_methods.rb +16 -0
- data/lib/Ifd_Automation/methods/IFD_webservice.rb +17 -0
- data/lib/Ifd_Automation/methods/core.rb +342 -0
- data/lib/Ifd_Automation/methods/database_methods.rb +25 -0
- data/lib/Ifd_Automation/methods/db_utils.rb +37 -0
- data/lib/Ifd_Automation/methods/error_handling_methods.rb +87 -0
- data/lib/Ifd_Automation/methods/javascript_handling_methods.rb +46 -0
- data/lib/Ifd_Automation/methods/lib_var.rb +59 -0
- data/lib/Ifd_Automation/methods/misc_methods.rb +33 -0
- data/lib/Ifd_Automation/methods/required_files.rb +33 -0
- data/lib/Ifd_Automation/methods/util.rb +168 -0
- data/lib/Ifd_Automation/methods/web_methods.rb +291 -0
- data/lib/Ifd_Automation/methods/web_service_methods.rb +63 -0
- data/lib/Ifd_Automation/version.rb +5 -0
- data/lib/Ifd_Automation.rb +1 -0
- metadata +439 -0
@@ -0,0 +1,342 @@
|
|
1
|
+
$_RP_OBJECT = {}
|
2
|
+
|
3
|
+
#Print script log to console
|
4
|
+
def put_log str
|
5
|
+
puts str if $_CFWEB['Print Log'] == true
|
6
|
+
end
|
7
|
+
|
8
|
+
#Call another step
|
9
|
+
def call_step str_step
|
10
|
+
put_log "\n-=> call step: #{str_step}"
|
11
|
+
step %{#{str_step}}
|
12
|
+
end
|
13
|
+
|
14
|
+
# Find object by Xpath
|
15
|
+
def find_object string_object
|
16
|
+
startTime = Time.new.to_i
|
17
|
+
string_object = string_object.gsub(/"/, "'")
|
18
|
+
# puts "String_object: #{string_object}"
|
19
|
+
locator_matching = /(.*?)(\{.*?\})/.match(string_object)
|
20
|
+
# puts "locator_matching : #{locator_matching}"
|
21
|
+
dyn_pros = {}
|
22
|
+
if locator_matching != nil
|
23
|
+
string_object = locator_matching[1]
|
24
|
+
eval(locator_matching[2].gsub(/['][\s,\t]*?:[\s,\t]*?[']?/, "'=>'")).each { |k, v|
|
25
|
+
dyn_pros[k.to_s.upcase] = v
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# put_log "\n---dyn_pros: #{dyn_pros}"
|
30
|
+
hash_object = $_RP_OBJECT[string_object]
|
31
|
+
if hash_object == nil
|
32
|
+
put_log ">>> OBJECT NAME MAYBE NOT FOUND!!!"
|
33
|
+
# true.should eq false
|
34
|
+
expect(true).to eq(false)
|
35
|
+
end
|
36
|
+
upcase_attrb = {}
|
37
|
+
if hash_object != nil
|
38
|
+
hash_object.each { |k, v|
|
39
|
+
k = k.to_s.upcase
|
40
|
+
# put_log "\n#{k} =~ /ph_/i and dyn_pros[#{k}]: #{k =~ /ph_/i and dyn_pros[k] != nil}"
|
41
|
+
if k =~ /ph_/i
|
42
|
+
if dyn_pros[k] != nil
|
43
|
+
# Assign place holder value to place holder property, also remove prefix ph_ from property key,
|
44
|
+
# also remove this pl from dyn_pros <= should be consider to continue transfer into inner object in relation
|
45
|
+
if v =~ /<ph_value>/i
|
46
|
+
upcase_attrb[k[3..k.size-1]] = v.gsub(/<ph_value>/i, dyn_pros[k])
|
47
|
+
else
|
48
|
+
upcase_attrb[k[3..k.size-1]] = dyn_pros[k]
|
49
|
+
end
|
50
|
+
|
51
|
+
dyn_pros.delete(k)
|
52
|
+
end
|
53
|
+
else
|
54
|
+
upcase_attrb[k.to_s.upcase] = v
|
55
|
+
end
|
56
|
+
|
57
|
+
}
|
58
|
+
end
|
59
|
+
if upcase_attrb.size > 0
|
60
|
+
strId = ""
|
61
|
+
strClass = ""
|
62
|
+
strName = ""
|
63
|
+
strTagname = ""
|
64
|
+
strXpathSelector = ""
|
65
|
+
strText = ""
|
66
|
+
|
67
|
+
index = nil
|
68
|
+
upcase_attrb.each { |key, value|
|
69
|
+
upcase_key = key.to_s.upcase
|
70
|
+
if upcase_key == "XPATH_SELECTOR"
|
71
|
+
strXpathSelector = value
|
72
|
+
end
|
73
|
+
}
|
74
|
+
continue_run = true;
|
75
|
+
|
76
|
+
if continue_run == true
|
77
|
+
begin
|
78
|
+
if strXpathSelector != nil and strXpathSelector.length > 0
|
79
|
+
foundElements = get_objects_by_XpathSelector(strXpathSelector)
|
80
|
+
else
|
81
|
+
#Generate Selector
|
82
|
+
strGenerateXpathSel = ""
|
83
|
+
strGenerateXpathSel = generate_xpath_selector(strId, strClass, strName, strTagname)
|
84
|
+
if strGenerateXpathSel.length > 0
|
85
|
+
foundElements = get_objects_by_XpathSelector(strGenerateXpathSel)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
if foundElements == nil or foundElements.length == 0
|
90
|
+
currentTime = Time.new.to_i
|
91
|
+
else
|
92
|
+
# put_log "\nBREAK!!!"
|
93
|
+
break
|
94
|
+
end
|
95
|
+
test = currentTime - startTime
|
96
|
+
# put_log "\n#TIMEOUNT:#{test} < #{$_CFWEB['Wait Time']}"
|
97
|
+
sleep(0.5)
|
98
|
+
end while (currentTime - startTime) < $_CFWEB['Wait Time']
|
99
|
+
|
100
|
+
if foundElements != nil or foundElements.length != 0
|
101
|
+
if index != nil and index.to_i >= 0
|
102
|
+
matched_index = 0;
|
103
|
+
return_element = nil
|
104
|
+
foundElements.each { |cur_element|
|
105
|
+
passCheck = find_object_check_object(cur_element, strId, strText)
|
106
|
+
if passCheck
|
107
|
+
if matched_index == index.to_i
|
108
|
+
return_element = cur_element
|
109
|
+
break
|
110
|
+
else
|
111
|
+
matched_index = matched_index + 1
|
112
|
+
end
|
113
|
+
end
|
114
|
+
}
|
115
|
+
return return_element
|
116
|
+
else
|
117
|
+
return_element = nil
|
118
|
+
foundElements.each { |cur_element|
|
119
|
+
passCheck = find_object_check_object(cur_element, strId, strText)
|
120
|
+
if passCheck
|
121
|
+
return_element = cur_element
|
122
|
+
break
|
123
|
+
end
|
124
|
+
}
|
125
|
+
return return_element
|
126
|
+
end # if index != nil and index.to_i >= 0
|
127
|
+
end #if foundElements != nil or foundElements.length != 0
|
128
|
+
end #if continue = true
|
129
|
+
end
|
130
|
+
|
131
|
+
return nil
|
132
|
+
end
|
133
|
+
|
134
|
+
#Generate Xpath Selector
|
135
|
+
def generate_xpath_selector(strId, strClass, strName, strTagname)
|
136
|
+
strGenerateXpathSel = ""
|
137
|
+
if strId != nil and strId.length > 0 and (strId =~ /^#/) == nil
|
138
|
+
strGenerateXpathSel = "[@id='#{strId}']"
|
139
|
+
end
|
140
|
+
if strClass != nil and strClass.length > 0 and (strClass =~ /^#/) == nil
|
141
|
+
strGenerateXpathSel = "#{strGenerateXpathSel}[@class='#{strClass}']"
|
142
|
+
end
|
143
|
+
if strName != nil and strName.length > 0 and (strName =~ /^#/) == nil
|
144
|
+
strGenerateXpathSel = "#{strGenerateXpathSel}[@name='#{strName}']"
|
145
|
+
end
|
146
|
+
|
147
|
+
if strGenerateXpathSel.length > 0
|
148
|
+
if strTagname != nil and strTagname.length > 0
|
149
|
+
strGenerateXpathSel = "//#{strTagname}#{strGenerateXpathSel}"
|
150
|
+
else
|
151
|
+
strGenerateXpathSel = "//*#{strGenerateXpathSel}"
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
return strGenerateXpathSel
|
156
|
+
end
|
157
|
+
|
158
|
+
#Get object by XpathSelector
|
159
|
+
def get_objects_by_XpathSelector(strXpathSelector)
|
160
|
+
# put_log "\nstrXpathSelector: #{strXpathSelector}"
|
161
|
+
foundElements = nil
|
162
|
+
begin
|
163
|
+
foundElements = page.all(:xpath, strXpathSelector)
|
164
|
+
rescue StandardError => myStandardError
|
165
|
+
put_log "\n>>> Error: #{myStandardError}"
|
166
|
+
end
|
167
|
+
|
168
|
+
return foundElements
|
169
|
+
end
|
170
|
+
|
171
|
+
#Find/Check the object by ID and Text
|
172
|
+
def find_object_check_object cur_element, strId, strText
|
173
|
+
passCheck = true
|
174
|
+
if cur_element != nil
|
175
|
+
|
176
|
+
# Check ID
|
177
|
+
if strId != nil and strId.length > 0
|
178
|
+
if strId =~ /^#/
|
179
|
+
strId = strId[1..-1]
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# Check Text
|
184
|
+
if passCheck and strText != nil and strText.length > 0
|
185
|
+
if (strText =~ /^#/)
|
186
|
+
strText = strText[1..-1]
|
187
|
+
end
|
188
|
+
end
|
189
|
+
return passCheck
|
190
|
+
end
|
191
|
+
|
192
|
+
return false
|
193
|
+
end
|
194
|
+
|
195
|
+
# Check object property
|
196
|
+
def execute_checkproperty element, property, negate, value, isSpecialChar=false
|
197
|
+
Capybara.configure do |config|
|
198
|
+
config.ignore_hidden_elements = false
|
199
|
+
end
|
200
|
+
foundElement = find_object(element)
|
201
|
+
|
202
|
+
check = false
|
203
|
+
if foundElement == nil and value == ""
|
204
|
+
check = true
|
205
|
+
# check.should eq true
|
206
|
+
expect(check).to eq true
|
207
|
+
else
|
208
|
+
put_log "\n\n\t>>> execute_checkproperty: finish to found element"
|
209
|
+
if foundElement != nil
|
210
|
+
if property.upcase == 'VALUE'
|
211
|
+
actual_value = foundElement.value()
|
212
|
+
|
213
|
+
elsif property.upcase == 'TEXT'
|
214
|
+
actual_value = foundElement.text()
|
215
|
+
|
216
|
+
elsif property.upcase == 'SPECIAL CHAR'
|
217
|
+
actual_value = foundElement.text()
|
218
|
+
isSpecialChar = true
|
219
|
+
|
220
|
+
elsif property.upcase == 'TAGNAME'
|
221
|
+
actual_value = foundElement.tag_name()
|
222
|
+
|
223
|
+
elsif property.upcase == 'STYLE'
|
224
|
+
actual_value = foundElement[:style]
|
225
|
+
|
226
|
+
elsif property.upcase == 'DISABLED'
|
227
|
+
actual_value = foundElement[:disabled]
|
228
|
+
|
229
|
+
elsif property.upcase == 'WIDTH'
|
230
|
+
actual_value = foundElement[:width]
|
231
|
+
|
232
|
+
elsif property.upcase == 'HEIGHT'
|
233
|
+
actual_value = foundElement[:height]
|
234
|
+
|
235
|
+
elsif property.upcase == 'ID'
|
236
|
+
actual_value = foundElement[:id]
|
237
|
+
|
238
|
+
elsif property.upcase == 'NAME'
|
239
|
+
actual_value = foundElement[:name]
|
240
|
+
|
241
|
+
elsif property.upcase == 'CLASS'
|
242
|
+
actual_value = foundElement[:class]
|
243
|
+
|
244
|
+
elsif property.upcase == 'HREF'
|
245
|
+
actual_value = foundElement[:href]
|
246
|
+
|
247
|
+
elsif property.upcase == 'TITLE'
|
248
|
+
actual_value = foundElement[:title]
|
249
|
+
|
250
|
+
elsif property.upcase == 'TYPE'
|
251
|
+
actual_value = foundElement[:type]
|
252
|
+
|
253
|
+
elsif property.upcase == 'CHECKED'
|
254
|
+
actual_value = "true" if foundElement.checked? == true
|
255
|
+
actual_value = "false" if foundElement.checked? == false
|
256
|
+
else
|
257
|
+
actual_value = foundElement["#{property}"]
|
258
|
+
end
|
259
|
+
|
260
|
+
if actual_value == nil
|
261
|
+
actual_value = ''
|
262
|
+
end
|
263
|
+
else
|
264
|
+
put_log "\nError >> Not found object: #{element}"
|
265
|
+
end
|
266
|
+
|
267
|
+
Capybara.configure do |config|
|
268
|
+
config.ignore_hidden_elements = true
|
269
|
+
end
|
270
|
+
|
271
|
+
if IFD_Assertion.reg_compare(actual_value, value, isSpecialChar)
|
272
|
+
check = true
|
273
|
+
end
|
274
|
+
|
275
|
+
put_log "\n#{property} :: Actual result is '#{actual_value}' -- Expected result is '#{value}'"
|
276
|
+
|
277
|
+
if negate == " not"
|
278
|
+
# check.should_not eq true
|
279
|
+
expect(check).not_to eql true
|
280
|
+
elsif
|
281
|
+
# check.should eq true
|
282
|
+
expect(check).to eq true
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
# Get text from web element
|
288
|
+
def execute_gettext element
|
289
|
+
foundElement = find_object(element)
|
290
|
+
if foundElement != nil
|
291
|
+
tagname = foundElement.tag_name()
|
292
|
+
|
293
|
+
if tagname.upcase == 'SELECT'
|
294
|
+
#@text = page.evaluate_script("$(\"##{foundElement[:id]}\").text()")
|
295
|
+
else
|
296
|
+
actual_text = foundElement.text()
|
297
|
+
if (actual_text == nil or actual_text.length == 0) and (tagname.upcase == 'INPUT' or tagname.upcase == 'TEXTAREA')
|
298
|
+
actual_text = foundElement.value()
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
put_log "\nText is '" + actual_text + "' of object '" + element + "'"
|
303
|
+
$context_value = actual_text
|
304
|
+
else
|
305
|
+
put_log "\nError >> Not found object: #{element}"
|
306
|
+
exit
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
def read_file(filename)
|
311
|
+
data = ''
|
312
|
+
f = File.open(filename, "r")
|
313
|
+
f.each_line do |line|
|
314
|
+
data += line
|
315
|
+
end
|
316
|
+
return data.strip;
|
317
|
+
end
|
318
|
+
|
319
|
+
def set_time_out(timeout)
|
320
|
+
$_CFWEB['Wait Time'] = timeout
|
321
|
+
Capybara.default_wait_time = $_CFWEB['Wait Time']
|
322
|
+
end
|
323
|
+
|
324
|
+
# method to get attribute value
|
325
|
+
# param 1 : String : Locator type (id, name, class, xpath, css)
|
326
|
+
# param 2 : String : Expected element text
|
327
|
+
# param 3 : String : atrribute name
|
328
|
+
def get_element_attribute(access_type, access_name, attribute_name)
|
329
|
+
$driver.find_element(:"#{access_type}" => "#{access_name}").attribute("#{attribute_name}")
|
330
|
+
end
|
331
|
+
|
332
|
+
#Get data from the 'testdata file'. if not valid, then testdataid is passed back
|
333
|
+
def getTestData(testdataid)
|
334
|
+
begin
|
335
|
+
sTestDataidArr = testdataid.downcase.split('.')
|
336
|
+
testdata = $testdata[sTestDataidArr.first][sTestDataidArr.last]
|
337
|
+
puts (testdata)
|
338
|
+
return testdata
|
339
|
+
rescue Exception
|
340
|
+
return testdataid
|
341
|
+
end
|
342
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class DatabaseMethods
|
2
|
+
def self.execute_select (schema,sql)
|
3
|
+
case $db_type.to_sym
|
4
|
+
when :sql_server then
|
5
|
+
conn = IFD_Connections.get_sql_server_db_connection(schema)
|
6
|
+
conn.execute sql
|
7
|
+
when :mysql then
|
8
|
+
conn = IFD_Connections.get_mysql_db_connection(schema)
|
9
|
+
conn.query sql
|
10
|
+
else
|
11
|
+
raise "*** ERROR: schema type (#{$db_type}) is not supported (SQL SERVER, MY SQL)."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.close_connection (schema)
|
16
|
+
case $db_type.to_sym
|
17
|
+
when :sql_server then
|
18
|
+
conn = IFD_Connections.get_sql_server_db_connection(schema)
|
19
|
+
conn.close
|
20
|
+
when :mysql then
|
21
|
+
conn = IFD_Connections.get_mysql_db_connection(schema)
|
22
|
+
conn.close
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class DB_Utils
|
2
|
+
def self.sql_value_format(value)
|
3
|
+
if value.nil?
|
4
|
+
return 'null'
|
5
|
+
else
|
6
|
+
value = value.gsub("'","''") if value.kind_of? String
|
7
|
+
return "'#{value}'"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.sql_value_format_prefix_wildcard(value)
|
12
|
+
if value.nil?
|
13
|
+
return 'null'
|
14
|
+
else
|
15
|
+
value = value.gsub("'","''") if value.kind_of? String
|
16
|
+
return "'#{value}%'"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.sql_value_format_suffix_wildcard(value)
|
21
|
+
if value.nil?
|
22
|
+
return 'null'
|
23
|
+
else
|
24
|
+
value = value.gsub("'","''") if value.kind_of? String
|
25
|
+
return "'%#{value}'"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.sql_value_format_wildcard(value)
|
30
|
+
if value.nil?
|
31
|
+
return 'null'
|
32
|
+
else
|
33
|
+
value = value.gsub("'","''") if value.kind_of? String
|
34
|
+
return "'%#{value}%'"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Error handling methods
|
2
|
+
|
3
|
+
# Method to check browser type
|
4
|
+
def validate_parameters(platform, browser_type, app_path)
|
5
|
+
if platform == 'desktop'
|
6
|
+
if !%w(ff ie chrome safari opera).include? browser_type
|
7
|
+
print_error_desktop
|
8
|
+
end
|
9
|
+
elsif platform == 'android'
|
10
|
+
print_error_android browser_type, app_path
|
11
|
+
elsif platform == 'iOS'
|
12
|
+
puts "Not Implemented..."
|
13
|
+
# print_error_ios browser_type, app_path
|
14
|
+
else
|
15
|
+
print_invalid_platform
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# print error for desktop
|
20
|
+
def print_error_desktop
|
21
|
+
puts "\nInappropraite desktop browser : \"#{ENV['BROWSER']}\""
|
22
|
+
puts "\nUsage : cucumber BROWSER=browser_name"
|
23
|
+
puts "\nBrowser Supported :\n"
|
24
|
+
puts "\n1.ie\n2.chrome\n3.ff\n4.safari\n5.opera"
|
25
|
+
Process.exit(0)
|
26
|
+
end
|
27
|
+
|
28
|
+
# print error for android
|
29
|
+
def print_error_android(browser_type, app_path)
|
30
|
+
if browser_type=='ff' and app_path==nil
|
31
|
+
puts "\nOops... not mentioned \"Browser\" or \"App path\""
|
32
|
+
print_error_android_app
|
33
|
+
print_error_android_web
|
34
|
+
Process.exit(0)
|
35
|
+
elsif browser_type!='ff' and !%w(native chrome).include? browser_type
|
36
|
+
puts "\nOops... not supported browser"
|
37
|
+
print_error_android_web
|
38
|
+
Process.exit(0)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# print error for android app
|
43
|
+
def print_error_android_app
|
44
|
+
puts "\nTo run test on android app"
|
45
|
+
puts "\n Usage : cucumber PLATFORM=android APP_PATH=path/to/app"
|
46
|
+
end
|
47
|
+
|
48
|
+
# print error for android web
|
49
|
+
def print_error_android_web
|
50
|
+
puts "\nTo run test on android mobile web"
|
51
|
+
puts "\n Usage : cucumber PLATFORM=android BROWSER=browser_name"
|
52
|
+
puts "\n Supported browsers are \"chrome\" and \"native\""
|
53
|
+
end
|
54
|
+
|
55
|
+
# print error for ios
|
56
|
+
def print_error_ios
|
57
|
+
if browser_type=='ff' and app_path==nil
|
58
|
+
puts "\nOops... not mentioned \"Browser\" or \"App path\""
|
59
|
+
print_error_ios_app
|
60
|
+
print_error_ios_web
|
61
|
+
Process.exit(0)
|
62
|
+
elsif browser_type!='safari'
|
63
|
+
puts "\nOops... not supported browser"
|
64
|
+
print_error_ios_app_web
|
65
|
+
Process.exit(0)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# print error for ios app
|
70
|
+
def print_error_ios_app
|
71
|
+
puts "\nTo run test on iOS App"
|
72
|
+
puts "\n Usage : cucumber PLATFORM=iOS APP_PATH=path/to/app"
|
73
|
+
end
|
74
|
+
|
75
|
+
# print error for ios web
|
76
|
+
def print_error_ios_web
|
77
|
+
puts "\nTo run test on iOS mobile web"
|
78
|
+
puts "\n Usage : cucumber PLATFORM=iOS BROWSER=safari"
|
79
|
+
end
|
80
|
+
|
81
|
+
# print error if invalid platform
|
82
|
+
def print_invalid_platform
|
83
|
+
puts "\nOops... Invalid Platform"
|
84
|
+
puts "\nSupported platform are \"android\" and \"iOS\"."
|
85
|
+
puts "\nTo run on Desktop no need to mention platform."
|
86
|
+
Process.exit(0)
|
87
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative 'required_files'
|
2
|
+
|
3
|
+
def handle_alert(decision)
|
4
|
+
if decision == 'accept'
|
5
|
+
page.driver.browser.switch_to.alert.accept
|
6
|
+
else
|
7
|
+
page.driver.browser.switch_to.alert.dismiss
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def switch_to_windows(decision)
|
12
|
+
if decision == 'last'
|
13
|
+
page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
|
14
|
+
else
|
15
|
+
page.driver.browser.switch_to.window(page.driver.browser.window_handles.first)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def close_windows
|
20
|
+
page.driver.browser.close
|
21
|
+
page.driver.browser.switch_to.window(page.driver.browser.window_handles[0])
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_browser_back
|
25
|
+
page.evaluate_script('window.history.back()')
|
26
|
+
end
|
27
|
+
|
28
|
+
def refresh_page
|
29
|
+
visit page.driver.browser.current_url
|
30
|
+
end
|
31
|
+
|
32
|
+
def open_new_windows_browser
|
33
|
+
page.driver.execute_script("window.open()")
|
34
|
+
end
|
35
|
+
|
36
|
+
# method to get javascript pop-up alert text
|
37
|
+
def get_alert_text
|
38
|
+
page.driver.browser.switch_to.alert.text
|
39
|
+
end
|
40
|
+
|
41
|
+
# method to check javascript pop-up alert text
|
42
|
+
def check_alert_text(text)
|
43
|
+
if get_alert_text != text
|
44
|
+
raise TestCaseFailed, "Text on alert pop up not matched, Actual Text : #{get_alert_text}, Expected Text : #{text}"
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
def var_collect string_var
|
2
|
+
if string_var =~ /^.*{year}.*$/
|
3
|
+
string_var = replace_year(string_var)
|
4
|
+
end
|
5
|
+
|
6
|
+
if string_var =~ /^.*{month}.*$/
|
7
|
+
string_var = replace_month(string_var)
|
8
|
+
end
|
9
|
+
|
10
|
+
if string_var =~ /^.*{day}.*$/
|
11
|
+
string_var = replace_day(string_var)
|
12
|
+
end
|
13
|
+
|
14
|
+
if string_var =~ /^.*{store_value}.*$/
|
15
|
+
string_var = $context_value
|
16
|
+
end
|
17
|
+
|
18
|
+
return string_var
|
19
|
+
end
|
20
|
+
|
21
|
+
def replace_year str
|
22
|
+
t = Time.now()
|
23
|
+
return str.gsub("{year}", t.year.to_s)
|
24
|
+
end
|
25
|
+
|
26
|
+
def replace_month str
|
27
|
+
t = Time.now()
|
28
|
+
_month = t.month
|
29
|
+
if _month < 10
|
30
|
+
return str.gsub("{month}", "0#{_month.to_s}")
|
31
|
+
else
|
32
|
+
return str.gsub("{month}", "#{_month.to_s}")
|
33
|
+
end
|
34
|
+
return str
|
35
|
+
end
|
36
|
+
|
37
|
+
def replace_day str
|
38
|
+
t = Time.now()
|
39
|
+
_day = t.day
|
40
|
+
if _day < 10
|
41
|
+
return str.gsub("{day}", "0#{_day.to_s}")
|
42
|
+
else
|
43
|
+
return str.gsub("{day}", "#{_day.to_s}")
|
44
|
+
end
|
45
|
+
return str
|
46
|
+
end
|
47
|
+
|
48
|
+
def replace_pipe str_pipe
|
49
|
+
put_log ">>>> #{str_pipe}"
|
50
|
+
if str_pipe =~ /^.*{pipe}.*$/
|
51
|
+
return str_pipe.gsub("{pipe}", "|")
|
52
|
+
end
|
53
|
+
return str_pipe
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# custome exception class
|
2
|
+
class TestCaseFailed < Exception
|
3
|
+
end
|
4
|
+
#
|
5
|
+
# # WAIT instance for explicit wait
|
6
|
+
# WAIT = Selenium::WebDriver::Wait.new(:timeout => 30)
|
7
|
+
#
|
8
|
+
# # method to validate locator
|
9
|
+
# def valid_locator_type? type
|
10
|
+
# %w(id class css name xpath).include? type
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# def validate_locator type
|
14
|
+
# raise "Invalid locator type - #{type}" unless valid_locator_type? type
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# # method to validate dropdown selector
|
18
|
+
# def valid_option_by? option_by
|
19
|
+
# %w(text value index).include? option_by
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# def validate_option_by option_by
|
23
|
+
# raise "Invalid option by - #{option_by}" unless valid_option_by? option_by
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# # Return android device name and android version using adb command
|
27
|
+
# def get_device_info
|
28
|
+
# IO.popen('adb shell getprop ro.product.brand') { |f| $device = f.gets.chomp.upcase}
|
29
|
+
# $device += ' '
|
30
|
+
# IO.popen('adb shell getprop ro.product.model') { |f| $device += f.gets.chomp.upcase}
|
31
|
+
# IO.popen('adb shell getprop ro.build.version.release') { |f| $os_version = f.gets.chomp.upcase}
|
32
|
+
# return $device, $os_version
|
33
|
+
# end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'selenium-webdriver'
|
3
|
+
require 'chunky_png'
|
4
|
+
require 'open-uri'
|
5
|
+
require 'rbconfig'
|
6
|
+
require 'appium_lib'
|
7
|
+
require 'rubygems'
|
8
|
+
require 'yaml'
|
9
|
+
require 'cucumber'
|
10
|
+
require 'mysql2'
|
11
|
+
require 'httparty'
|
12
|
+
require 'csv'
|
13
|
+
require 'rack/utf8_sanitizer'
|
14
|
+
require 'rautomation'
|
15
|
+
require 'net/https'
|
16
|
+
include RbConfig
|
17
|
+
|
18
|
+
require_relative 'misc_methods'
|
19
|
+
require_relative 'error_handling_methods'
|
20
|
+
require_relative 'core'
|
21
|
+
require_relative 'database_methods'
|
22
|
+
require_relative 'db_utils'
|
23
|
+
require_relative 'IFD_Assertion_methods'
|
24
|
+
require_relative 'IFD_Connection'
|
25
|
+
require_relative 'IFD_email_methods'
|
26
|
+
require_relative 'IFD_webservice'
|
27
|
+
require_relative 'javascript_handling_methods'
|
28
|
+
require_relative 'lib_var'
|
29
|
+
require_relative 'util'
|
30
|
+
require_relative 'web_methods'
|
31
|
+
require_relative 'web_service_methods'
|
32
|
+
|
33
|
+
|