selenium-framework 0.0.4
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.
- data/bin/copyfiles/Gemfile +10 -0
- data/bin/copyfiles/include.rb +12 -0
- data/bin/copyfiles/project_file.rb +25 -0
- data/bin/framework +297 -0
- data/lib/modules/login/login.rb +14 -0
- data/lib/selenium-framework.rb +10 -0
- data/lib/userextension/user_extension.rb +239 -0
- metadata +52 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
require './include.rb'
|
2
|
+
|
3
|
+
class Project < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
7
|
+
client.timeout = 120 # seconds
|
8
|
+
$driver = Selenium::WebDriver.for(:remote, :http_client => client, :url => 'http://<IP ADDRESS>:<PORT NUMBER>/wd/hub', :desired_capabilities => ':firefox')
|
9
|
+
$base_url = 'http://<WEBSITE URL>'
|
10
|
+
$driver.manage.timeouts.implicit_wait = 180
|
11
|
+
@verification_errors = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
$driver.quit
|
16
|
+
assert_equal [],@verification_errors
|
17
|
+
end
|
18
|
+
|
19
|
+
def verify(&blk)
|
20
|
+
yield
|
21
|
+
rescue Test::Unit::AssertionFailedError => ex
|
22
|
+
@verification_errors << ex
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/bin/framework
ADDED
@@ -0,0 +1,297 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
require 'readline'
|
4
|
+
|
5
|
+
|
6
|
+
def print_path(filename, filepath, project_directory_path)
|
7
|
+
path = filepath +"/"+ filename
|
8
|
+
path = path.to_s
|
9
|
+
puts "create " + path.split(project_directory_path.to_s)[1].to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_dir(dirname, directory_path, project_directory_path)
|
13
|
+
Dir.chdir(directory_path)
|
14
|
+
unless (File.exists?(dirname))
|
15
|
+
Dir.mkdir(dirname)
|
16
|
+
print_path(dirname, directory_path, project_directory_path)
|
17
|
+
end
|
18
|
+
Dir.chdir(directory_path + "/" + dirname)
|
19
|
+
unless (File.exists?(".gitignore"))
|
20
|
+
FileUtils.touch ".gitignore"
|
21
|
+
print_path(".gitignore", directory_path + "/" + dirname, project_directory_path)
|
22
|
+
end
|
23
|
+
Dir.chdir(directory_path)
|
24
|
+
end
|
25
|
+
|
26
|
+
def help_text
|
27
|
+
puts "Usage: \n\tframework new <PROJECT_PATH> [options] \n\tframework update <PROJECT_PATH> [options]\n\nFramework options: \n\t-h, [--help]\t# Show this help message and quit\n\nRuntime options: \n\t-f, [--force]\t# Overwrite files that already exist"
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
if ARGV[0] == nil || ARGV[1] == nil || (ARGV[0] !='new' && ARGV[0] !='update' ) || ARGV[0] == '-h' || ARGV[0] == '--help'
|
33
|
+
help_text
|
34
|
+
end
|
35
|
+
force_flag = 0
|
36
|
+
if ARGV.length == 3
|
37
|
+
if ARGV[2] == '-f' || ARGV[2] == '--force'
|
38
|
+
exist_flag = 1
|
39
|
+
force_flag = 1
|
40
|
+
else
|
41
|
+
help_text
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
update_flag = 0
|
46
|
+
if ARGV[0] == 'update'
|
47
|
+
if ARGV.length == 2 && ARGV[1] != nil
|
48
|
+
update_flag = 1
|
49
|
+
else
|
50
|
+
help_text
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
project_name = ARGV[1]
|
57
|
+
project_directory_path = Dir.pwd
|
58
|
+
puts "\n"
|
59
|
+
|
60
|
+
exist_flag = 1
|
61
|
+
if ("true".casecmp(File.directory?(project_directory_path +"/"+ project_name).to_s)) == 0 && exist_flag == 1 && force_flag == 0 && update_flag == 0
|
62
|
+
puts "Project exist !!! What do you want to do? \n1. Overwrite the project\n2. Take backup and create new project\n3. Create project in existing directory\n4. Exit :\n\n"
|
63
|
+
exist_flag = Readline.readline(":", true)
|
64
|
+
exist_flag = exist_flag.to_i
|
65
|
+
else
|
66
|
+
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
if exist_flag == 1 && update_flag == 0
|
71
|
+
if File.exists?(project_name)
|
72
|
+
FileUtils.rm_r(project_name)
|
73
|
+
puts "Deleted the previous project...\n\n"
|
74
|
+
end
|
75
|
+
puts "Creating new project as #{project_name}..."
|
76
|
+
create_dir(project_name, project_directory_path, project_directory_path)
|
77
|
+
Dir.chdir(project_directory_path + "/" + project_name)
|
78
|
+
|
79
|
+
project_main_file = project_name + ".rb"
|
80
|
+
FileUtils.touch project_main_file
|
81
|
+
source = File.expand_path File.dirname(__FILE__).to_s + "/copyfiles/project_file.rb"
|
82
|
+
destination = project_directory_path + "/" + project_name + "/" + project_main_file
|
83
|
+
FileUtils.copy_file(source,destination)
|
84
|
+
outdata = File.read(destination).gsub("Project", project_name.capitalize)
|
85
|
+
File.open(destination, 'w') do |out|
|
86
|
+
out << outdata
|
87
|
+
end
|
88
|
+
print_path(project_main_file, project_directory_path + "/" + project_name, project_directory_path)
|
89
|
+
|
90
|
+
FileUtils.touch "include.rb"
|
91
|
+
source = File.expand_path File.dirname(__FILE__).to_s + "/copyfiles/include.rb"
|
92
|
+
destination = project_directory_path + "/" + project_name + "/include.rb"
|
93
|
+
FileUtils.copy_file(source,destination)
|
94
|
+
print_path("include.rb", project_directory_path + "/" + project_name, project_directory_path)
|
95
|
+
|
96
|
+
FileUtils.touch "Gemfile"
|
97
|
+
source = File.expand_path File.dirname(__FILE__).to_s + "/copyfiles/Gemfile"
|
98
|
+
destination = project_directory_path + "/" + project_name + "/Gemfile"
|
99
|
+
FileUtils.copy_file(source,destination)
|
100
|
+
print_path("Gemfile", project_directory_path + "/" + project_name, project_directory_path)
|
101
|
+
|
102
|
+
Dir.chdir(project_directory_path)
|
103
|
+
# internal_dir -- array for storing framework directory names
|
104
|
+
internal_dir = ["libraries", "testcases", "logs", "reports", "screenshots"]
|
105
|
+
directory_path = project_directory_path + "/" + project_name
|
106
|
+
# dir_counter -- iterator for the loop
|
107
|
+
for dir_counter in 0..internal_dir.length-1
|
108
|
+
create_dir(internal_dir[dir_counter], directory_path, project_directory_path)
|
109
|
+
end
|
110
|
+
puts "\nFramework for #{project_name} is created..."
|
111
|
+
puts "\nbundle install"
|
112
|
+
Dir.chdir(project_directory_path + "/" + project_name)
|
113
|
+
system("bundle install")
|
114
|
+
Dir.chdir(project_directory_path)
|
115
|
+
end
|
116
|
+
|
117
|
+
if exist_flag == 2
|
118
|
+
timestamp = Time.now
|
119
|
+
timestamp = timestamp.strftime("%d-%m-%Y-%H-%M-%S")
|
120
|
+
timestamp = timestamp.to_s
|
121
|
+
old_prject_name = project_name
|
122
|
+
new_project_name = project_name+'_'+timestamp
|
123
|
+
File.rename(old_prject_name, new_project_name)
|
124
|
+
puts "\n#{old_prject_name} HAS BEEN MOVED TO #{new_project_name} \n\n"
|
125
|
+
puts "Creating new project as #{project_name}..."
|
126
|
+
create_dir(project_name, project_directory_path, project_directory_path)
|
127
|
+
Dir.chdir(project_directory_path + "/" + project_name)
|
128
|
+
|
129
|
+
project_main_file = project_name + ".rb"
|
130
|
+
FileUtils.touch project_main_file
|
131
|
+
source = File.expand_path File.dirname(__FILE__).to_s + "/copyfiles/project_file.rb"
|
132
|
+
destination = project_directory_path + "/" + project_name + "/" + project_main_file
|
133
|
+
FileUtils.copy_file(source,destination)
|
134
|
+
outdata = File.read(destination).gsub("Project", project_name.capitalize)
|
135
|
+
File.open(destination, 'w') do |out|
|
136
|
+
out << outdata
|
137
|
+
end
|
138
|
+
print_path(project_main_file, project_directory_path + "/" + project_name, project_directory_path)
|
139
|
+
|
140
|
+
FileUtils.touch "include.rb"
|
141
|
+
source = File.expand_path File.dirname(__FILE__).to_s + "/copyfiles/include.rb"
|
142
|
+
destination = project_directory_path + "/" + project_name + "/include.rb"
|
143
|
+
FileUtils.copy_file(source,destination)
|
144
|
+
print_path("include.rb", project_directory_path + "/" + project_name, project_directory_path)
|
145
|
+
|
146
|
+
FileUtils.touch "Gemfile"
|
147
|
+
source = File.expand_path File.dirname(__FILE__).to_s + "/copyfiles/Gemfile"
|
148
|
+
destination = project_directory_path + "/" + project_name + "/Gemfile"
|
149
|
+
FileUtils.copy_file(source,destination)
|
150
|
+
print_path("Gemfile", project_directory_path + "/" + project_name, project_directory_path)
|
151
|
+
|
152
|
+
Dir.chdir(project_directory_path)
|
153
|
+
# internal_dir -- array for storing framework directory names
|
154
|
+
internal_dir = ["libraries", "testcases", "logs", "reports", "screenshots"]
|
155
|
+
directory_path = project_directory_path + "/" + project_name
|
156
|
+
# dir_counter -- iterator for the loop
|
157
|
+
for dir_counter in 0..internal_dir.length-1
|
158
|
+
create_dir(internal_dir[dir_counter], directory_path, project_directory_path)
|
159
|
+
end
|
160
|
+
puts "\nFramework for #{project_name} is created..."
|
161
|
+
puts "\nbundle install"
|
162
|
+
Dir.chdir(project_directory_path + "/" + project_name)
|
163
|
+
system("bundle install")
|
164
|
+
Dir.chdir(project_directory_path)
|
165
|
+
end
|
166
|
+
|
167
|
+
if exist_flag == 3
|
168
|
+
puts "\nThe framework will be created in existing directory. Do you want to continue? Enter y/yes to continue."
|
169
|
+
confirm_flag = Readline.readline(":", true)
|
170
|
+
confirm_flag = confirm_flag.to_s.upcase
|
171
|
+
if ("Y".casecmp confirm_flag) == 0 || ("YES".casecmp confirm_flag) == 0
|
172
|
+
Dir.chdir(project_directory_path + "/" + project_name)
|
173
|
+
project_main_file = project_name + ".rb"
|
174
|
+
unless (File.exists?(project_main_file))
|
175
|
+
FileUtils.touch project_main_file
|
176
|
+
source = File.expand_path File.dirname(__FILE__).to_s + "/copyfiles/project_file.rb"
|
177
|
+
destination = project_directory_path + "/" + project_name + "/" + project_main_file
|
178
|
+
FileUtils.copy_file(source,destination)
|
179
|
+
outdata = File.read(destination).gsub("Project", project_name.capitalize)
|
180
|
+
File.open(destination, 'w') do |out|
|
181
|
+
out << outdata
|
182
|
+
end
|
183
|
+
print_path(project_main_file, project_directory_path + "/" + project_name, project_directory_path)
|
184
|
+
end
|
185
|
+
unless (File.exists?("include.rb"))
|
186
|
+
FileUtils.touch "include.rb"
|
187
|
+
source = File.expand_path File.dirname(__FILE__).to_s + "/copyfiles/include.rb"
|
188
|
+
destination = project_directory_path + "/" + project_name + "/include.rb"
|
189
|
+
FileUtils.copy_file(source,destination)
|
190
|
+
print_path("include.rb", project_directory_path + "/" + project_name, project_directory_path)
|
191
|
+
end
|
192
|
+
unless (File.exists?("Gemfile"))
|
193
|
+
FileUtils.touch "Gemfile"
|
194
|
+
source = File.expand_path File.dirname(__FILE__).to_s + "/copyfiles/Gemfile"
|
195
|
+
destination = project_directory_path + "/" + project_name + "/Gemfile"
|
196
|
+
FileUtils.copy_file(source,destination)
|
197
|
+
print_path("Gemfile", project_directory_path + "/" + project_name, project_directory_path)
|
198
|
+
end
|
199
|
+
|
200
|
+
Dir.chdir(project_directory_path)
|
201
|
+
# internal_dir -- array for storing framework directory names
|
202
|
+
internal_dir = ["libraries", "testcases", "logs", "reports", "screenshots"]
|
203
|
+
directory_path = project_directory_path + "/" + project_name
|
204
|
+
# dir_counter -- iterator for the loop
|
205
|
+
for dir_counter in 0..internal_dir.length-1
|
206
|
+
create_dir(internal_dir[dir_counter], directory_path, project_directory_path)
|
207
|
+
end
|
208
|
+
puts "\nFramework for #{project_name} is created..."
|
209
|
+
puts "\nbundle install"
|
210
|
+
Dir.chdir(project_directory_path + "/" + project_name)
|
211
|
+
system("bundle install")
|
212
|
+
Dir.chdir(project_directory_path)
|
213
|
+
else
|
214
|
+
puts "Not continuing. Exiting creation of framework..."
|
215
|
+
exit
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
if exist_flag == 4
|
220
|
+
puts "Project exist !!! So exiting..."
|
221
|
+
exit
|
222
|
+
end
|
223
|
+
|
224
|
+
if update_flag ==1
|
225
|
+
unless File.exists?(project_name)
|
226
|
+
puts "\n#{project_name} does not exist in current location...\nSo exiting ..."
|
227
|
+
exit
|
228
|
+
end
|
229
|
+
Dir.chdir(project_directory_path + "/" + project_name)
|
230
|
+
source = File.expand_path File.dirname(__FILE__).to_s + "/copyfiles/include.rb"
|
231
|
+
destination = "include.rb"
|
232
|
+
compare_result_1 = FileUtils.compare_file(source, destination).to_s
|
233
|
+
source = File.expand_path File.dirname(__FILE__).to_s + "/copyfiles/Gemfile"
|
234
|
+
destination = "Gemfile"
|
235
|
+
compare_result_2 = FileUtils.compare_file(source, destination).to_s
|
236
|
+
|
237
|
+
if ("true".casecmp compare_result_1) == 0 && ("true".casecmp compare_result_2) == 0
|
238
|
+
puts "\nFramework for #{project_name} is already updated..."
|
239
|
+
puts "\nbundle install"
|
240
|
+
Dir.chdir(project_directory_path + "/" + project_name)
|
241
|
+
system("bundle install")
|
242
|
+
Dir.chdir(project_directory_path)
|
243
|
+
exit
|
244
|
+
else
|
245
|
+
puts "\nFramework for #{project_name} needs to be updated..."
|
246
|
+
source = File.expand_path File.dirname(__FILE__).to_s + "/copyfiles/include.rb"
|
247
|
+
destination = "include.rb"
|
248
|
+
source_data = Array.new
|
249
|
+
source_data = IO.readlines(source)
|
250
|
+
destination_data = Array.new
|
251
|
+
destination_data = IO.readlines(destination)
|
252
|
+
source_data.each do |thing|
|
253
|
+
present_flag = destination_data.include? thing
|
254
|
+
present_flag = present_flag.to_s
|
255
|
+
if ("false".casecmp present_flag) == 0
|
256
|
+
#File.open(destination, 'a+') { |file| file.write(thing.to_s) }
|
257
|
+
f = File.open(destination, "r+")
|
258
|
+
lines = f.readlines
|
259
|
+
f.close
|
260
|
+
lines = [thing] + lines
|
261
|
+
output = File.new(destination, "w")
|
262
|
+
lines.each { |line| output.write line }
|
263
|
+
output.close
|
264
|
+
end
|
265
|
+
end
|
266
|
+
print_path("include.rb", project_directory_path + "/" + project_name, project_directory_path)
|
267
|
+
|
268
|
+
source = File.expand_path File.dirname(__FILE__).to_s + "/copyfiles/Gemfile"
|
269
|
+
destination = "Gemfile"
|
270
|
+
source_data = Array.new
|
271
|
+
source_data = IO.readlines(source)
|
272
|
+
destination_data = Array.new
|
273
|
+
destination_data = IO.readlines(destination)
|
274
|
+
source_data.each do |thing|
|
275
|
+
present_flag = destination_data.include? thing
|
276
|
+
present_flag = present_flag.to_s
|
277
|
+
if ("false".casecmp present_flag) == 0
|
278
|
+
#File.open(destination, 'a+') { |file| file.write(thing.to_s) }
|
279
|
+
f = File.open(destination, "r+")
|
280
|
+
lines = f.readlines
|
281
|
+
f.close
|
282
|
+
lines = [thing] + lines
|
283
|
+
output = File.new(destination, "w")
|
284
|
+
lines.each { |line| output.write line }
|
285
|
+
output.close
|
286
|
+
end
|
287
|
+
end
|
288
|
+
print_path("Gemfile", project_directory_path + "/" + project_name, project_directory_path)
|
289
|
+
|
290
|
+
puts "\nFramework for #{project_name} is updated..."
|
291
|
+
puts "\nbundle install"
|
292
|
+
Dir.chdir(project_directory_path + "/" + project_name)
|
293
|
+
system("bundle install")
|
294
|
+
Dir.chdir(project_directory_path)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Login
|
2
|
+
|
3
|
+
def self.login(user_loc_type, user_locator, username, pass_loc_type, pass_locator, password, submit_loc_type, submit_locator)
|
4
|
+
$driver.find_element(user_loc_type.to_sym, user_locator).send_keys username
|
5
|
+
$driver.find_element(pass_loc_type.to_sym, pass_locator).send_keys password
|
6
|
+
$driver.find_element(submit_loc_type.to_sym, submit_locator).click
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.forgot_password(user_loc_type, user_locator, username, submit_loc_type, submit_locator)
|
10
|
+
$driver.find_element(user_loc_type.to_sym, user_locator).send_keys username
|
11
|
+
$driver.find_element(submit_loc_type.to_sym, submit_locator).click
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,239 @@
|
|
1
|
+
class UserExtension
|
2
|
+
|
3
|
+
# Call this function this way "generate_mail_id(length, domain)".
|
4
|
+
# This function will generate a random Yopmail id and return it.
|
5
|
+
def self.generate_mail_id(length, domain)
|
6
|
+
yopmailid = (1..length).map { ('a'..'z').to_a[rand(26)] }.join+"@"+domain.to_s
|
7
|
+
return yopmailid
|
8
|
+
end
|
9
|
+
|
10
|
+
# Call this function this way "generate_string(length)".
|
11
|
+
# This function will generate a random string and return it.
|
12
|
+
def self.generate_string(length)
|
13
|
+
str = (1..length).map { ('a'..'z').to_a[rand(26)] }.join
|
14
|
+
return str
|
15
|
+
end
|
16
|
+
|
17
|
+
# Call this function this way "generate_title".
|
18
|
+
# This function will generate a title and return it.
|
19
|
+
def self.generate_title
|
20
|
+
title = Faker::Name.prefix
|
21
|
+
return title
|
22
|
+
end
|
23
|
+
|
24
|
+
# Call this function this way "generate_name(length)".
|
25
|
+
# This function will generate a random name and return it.
|
26
|
+
def self.generate_name(length)
|
27
|
+
str = (1..length-1).map { ('a'..'z').to_a[rand(26)] }.join
|
28
|
+
str = ('A'..'Z').to_a[rand(26)] + str
|
29
|
+
#str = Faker::Name.first_name
|
30
|
+
#while str.length != length
|
31
|
+
# str = Faker::Name.first_name
|
32
|
+
#end
|
33
|
+
str.capitalize
|
34
|
+
return str
|
35
|
+
end
|
36
|
+
|
37
|
+
# Call this function this way "generate_number(minrange, maxrange)".
|
38
|
+
# This function will generate a random number and return it.
|
39
|
+
def self.generate_number(minrange, maxrange)
|
40
|
+
number = rand(minrange..maxrange)
|
41
|
+
return number
|
42
|
+
end
|
43
|
+
|
44
|
+
# Call this function this way "generate_future_date(days)".
|
45
|
+
# This function will generate a future date and return it.
|
46
|
+
def self.generate_future_date(days)
|
47
|
+
date = Date.strptime(Date.today.to_s)
|
48
|
+
date = date + days
|
49
|
+
return date.strftime("%d-%m-%Y")
|
50
|
+
end
|
51
|
+
|
52
|
+
# Call this function this way "generate_past_date(days)".
|
53
|
+
# This function will generate a past date and return it.
|
54
|
+
def self.generate_past_date(days)
|
55
|
+
date = Date.strptime(Date.today.to_s)
|
56
|
+
date = date - days
|
57
|
+
return date.strftime("%d-%m-%Y")
|
58
|
+
end
|
59
|
+
|
60
|
+
# Call this function this way "generate_alphanumeric_string(length)".
|
61
|
+
# This function will generate a random alpha-numeric string and return it.
|
62
|
+
def self.generate_alphanumeric_string(length)
|
63
|
+
str = (1..length).map { rand(36).to_s(36) }.join
|
64
|
+
return str
|
65
|
+
end
|
66
|
+
|
67
|
+
# Call this function this way "generate_street_address".
|
68
|
+
# This function will generate a random street address and return it.
|
69
|
+
def self.generate_street_address
|
70
|
+
street_address = Faker::Address.street_address
|
71
|
+
return street_address
|
72
|
+
end
|
73
|
+
|
74
|
+
# Call this function this way "generate_address".
|
75
|
+
# This function will generate a random address and return it.
|
76
|
+
def self.generate_address
|
77
|
+
address = Faker::Address.secondary_address
|
78
|
+
return address
|
79
|
+
end
|
80
|
+
|
81
|
+
# Call this function this way "generate_phone_number".
|
82
|
+
# This function will generate a random phone number and return it.
|
83
|
+
def self.generate_phone_number
|
84
|
+
phone_number = rand(1000000000..9999999999)
|
85
|
+
return phone_number
|
86
|
+
end
|
87
|
+
|
88
|
+
# Call this function this way "generate_paragraph".
|
89
|
+
# This function will generate a paragraph and return it.
|
90
|
+
def self.generate_paragraph
|
91
|
+
paragraph = Faker::Lorem.paragraphs.map { |i| i.to_s }.join(" ")
|
92
|
+
return paragraph
|
93
|
+
end
|
94
|
+
|
95
|
+
# Call this function this way "generate_words(number)".
|
96
|
+
# This function will generate words and return it.
|
97
|
+
def self.generate_words(number)
|
98
|
+
words = Faker::Lorem.words(number).map { |i| i.to_s }.join(" ")
|
99
|
+
return words
|
100
|
+
end
|
101
|
+
|
102
|
+
# Call this function this way "generate_sentence".
|
103
|
+
# This function will generate a sentence and return it.
|
104
|
+
def self.generate_sentence
|
105
|
+
sentence = Faker::Lorem.sentence
|
106
|
+
return sentence
|
107
|
+
end
|
108
|
+
|
109
|
+
# Call this function this way "write_result_to_csv(report_file, test_id, test_case, result, comment="")".
|
110
|
+
# This function will write the result to .csv file.
|
111
|
+
def self.write_result_to_csv(report_file, test_id, test_case, result, comment="")
|
112
|
+
CSV.open(report_file, "ab") do |csv_file|
|
113
|
+
csv_file << [test_id, test_case, result, comment]
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# Call this function this way "write_logs_to_text_file(log_file, logs)".
|
118
|
+
# This function will write the logs to .log file.
|
119
|
+
def self.write_logs_to_text_file(log_file, logs)
|
120
|
+
File.open(log_file, "a") do |txt_file|
|
121
|
+
txt_file.puts logs
|
122
|
+
txt_file.puts "\n"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# Call this function this way "element_present?(how, what)".
|
127
|
+
# This function will check if the element is present or not.
|
128
|
+
def self.element_present?(how, what)
|
129
|
+
begin
|
130
|
+
$driver.find_element(how, what)
|
131
|
+
return true
|
132
|
+
rescue
|
133
|
+
return false
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# Call this function this way "pre_requisite(build_no,browser,timestamp)".
|
138
|
+
# This function will create the pre-requisites for the project.
|
139
|
+
def self.pre_requisite(build_no, browser, timestamp)
|
140
|
+
returning_array = Array.new
|
141
|
+
build_no = build_no.to_s
|
142
|
+
browser = browser.to_s
|
143
|
+
timestamp = timestamp.to_s
|
144
|
+
store_path = Dir.pwd
|
145
|
+
Dir.chdir("screenshots")
|
146
|
+
Dir.mkdir(build_no)
|
147
|
+
Dir.chdir(build_no)
|
148
|
+
Dir.mkdir(browser +"_"+ timestamp)
|
149
|
+
Dir.chdir(browser +"_"+ timestamp)
|
150
|
+
screenshot_path = store_path + "/screenshots/" + build_no + "/" + browser +"_"+ timestamp + "/"
|
151
|
+
returning_array.push(screenshot_path)
|
152
|
+
Dir.chdir(store_path)
|
153
|
+
|
154
|
+
Dir.chdir("reports")
|
155
|
+
Dir.mkdir(build_no)
|
156
|
+
report_path = store_path + "/reports/" + build_no + "/"
|
157
|
+
Dir.chdir(report_path)
|
158
|
+
report_file = report_path + build_no +"_" + browser +"_"+ timestamp + ".csv"
|
159
|
+
FileUtils.touch(report_file)
|
160
|
+
CSV.open(report_file, "wb") do |csv_file|
|
161
|
+
csv_file << ["TEST_ID", "TEST_CASE", "RESULT", "COMMENTS"]
|
162
|
+
end
|
163
|
+
returning_array.push(report_file)
|
164
|
+
broken_links_report_file = report_path + build_no +"_broken_links_" + timestamp + ".csv"
|
165
|
+
FileUtils.touch(broken_links_report_file)
|
166
|
+
CSV.open(broken_links_report_file, "wb") do |csv_file|
|
167
|
+
csv_file << ["LINK", "RESPONSE", "COMMENTS"]
|
168
|
+
end
|
169
|
+
returning_array.push(broken_links_report_file)
|
170
|
+
Dir.chdir(store_path)
|
171
|
+
|
172
|
+
Dir.chdir("logs")
|
173
|
+
Dir.mkdir(build_no)
|
174
|
+
log_path = store_path + "/logs/" + build_no + "/"
|
175
|
+
Dir.chdir(log_path)
|
176
|
+
log_file = log_path + build_no +"_" + browser + "_" + timestamp + ".log"
|
177
|
+
FileUtils.touch(log_file)
|
178
|
+
File.open(log_file, "wb") do |txt_file|
|
179
|
+
txt_file.puts "LOGS WITH RESULTS"
|
180
|
+
end
|
181
|
+
returning_array.push(log_file)
|
182
|
+
Dir.chdir(store_path)
|
183
|
+
|
184
|
+
return returning_array
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
def self.init_record()
|
189
|
+
os = RUBY_PLATFORM
|
190
|
+
if os.include? "linux"
|
191
|
+
headless_obj = Headless.new
|
192
|
+
headless_obj.start
|
193
|
+
return headless_obj
|
194
|
+
else
|
195
|
+
puts "#{RUBY_PLATFORM} is not a linux platform !!!"
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
|
200
|
+
def self.record_video_start_capture(headless_obj)
|
201
|
+
os = RUBY_PLATFORM
|
202
|
+
if os.include? "linux"
|
203
|
+
headless_obj.video.start_capture
|
204
|
+
else
|
205
|
+
puts "#{RUBY_PLATFORM} is not a linux platform !!!"
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
def self.record_video_stop_and_save(headless_obj,filename)
|
211
|
+
os = RUBY_PLATFORM
|
212
|
+
if os.include? "linux"
|
213
|
+
headless_obj.video.stop_and_save(filename)
|
214
|
+
else
|
215
|
+
puts "#{RUBY_PLATFORM} is not a linux platform !!!"
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
|
220
|
+
def self.record_video_stop_and_discard(headless_obj)
|
221
|
+
os = RUBY_PLATFORM
|
222
|
+
if os.include? "linux"
|
223
|
+
headless_obj.video.stop_and_discard()
|
224
|
+
else
|
225
|
+
puts "#{RUBY_PLATFORM} is not a linux platform !!!"
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
|
230
|
+
def self.capture_screenshot(selenium_diver,filename)
|
231
|
+
browser_name = selenium_diver.capabilities.browser_name
|
232
|
+
unless (browser_name.include? "safari")
|
233
|
+
selenium_diver.save_screenshot filename
|
234
|
+
else
|
235
|
+
puts "#{browser_name} does not support for capturing screenshot !!!"
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
end
|
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: selenium-framework
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Suyog Sakegaonkar, Thiyagarajan Veluchamy
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-31 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Selenium Automation FrameWork
|
15
|
+
email: suyogsakegaonkar@gmail.com, thiyagarajannv@gmail.com
|
16
|
+
executables:
|
17
|
+
- framework
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/userextension/user_extension.rb
|
22
|
+
- lib/selenium-framework.rb
|
23
|
+
- lib/modules/login/login.rb
|
24
|
+
- bin/copyfiles/Gemfile
|
25
|
+
- bin/copyfiles/include.rb
|
26
|
+
- bin/copyfiles/project_file.rb
|
27
|
+
- bin/framework
|
28
|
+
homepage: https://github.com/webonise/AutomationFramework
|
29
|
+
licenses: []
|
30
|
+
post_install_message: ''
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 1.8.25
|
49
|
+
signing_key:
|
50
|
+
specification_version: 3
|
51
|
+
summary: This gem is used for automation framework
|
52
|
+
test_files: []
|