awetestlib 0.0.2-x86-mingw32

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/lib/version.rb ADDED
@@ -0,0 +1,4 @@
1
+ module Awetestlib
2
+ VERSION = "0.0.2"
3
+ VERSION_DATE = "2012-07-12"
4
+ end
data/zoho_util.rb ADDED
@@ -0,0 +1,484 @@
1
+ module ZohoUtil
2
+
3
+ def run
4
+ if @xls_path
5
+ get_variables(@xls_path, :role)
6
+ @login.each_key do |key|
7
+ if @login[key]['enabled'] == 'Y'
8
+ @user = @login[key]['userid']
9
+ @pass = @login[key]['password']
10
+ @role = @login[key]['role']
11
+ @url1 = @login[key]['url']
12
+ debug_to_report("@user: #{@user}, @pass: #{@pass}, @role: #{@role} (#{__LINE__})")
13
+ break
14
+ end
15
+ end
16
+ end
17
+
18
+ #userid = "joeklienwatir@gmail.com" #@zohologin.cell(2,2)
19
+ #password = 'watir001' #@zohologin.cell(2,3)
20
+ #login_url = "https://accounts.zoho.com/login?serviceurl=https://www.zoho.com/&hide_signup=true&css=https://www.zoho.com/css/login.css"
21
+ home_url = 'https://crm.zoho.com/crm/ShowHomePage.do'
22
+ validation = 'Welcome joeklienwatir at Software'
23
+
24
+ browser = open_browser
25
+ go_to_url(browser, @url1)
26
+ zoho_login(browser, @user, @pass, home_url, validation)
27
+ run_test(browser)
28
+ logout(browser)
29
+
30
+ rescue
31
+ fatal_to_log("#{@myName} '#{$!}'")
32
+ browser.close
33
+ raise
34
+ end
35
+
36
+ def zoho_login(browser, userid, password, url, validation = 'Welcome joeklienwatir at Software')
37
+ mark_testlevel("#{__method__.to_s.titleize}", 8)
38
+ set_textfield_by_name(browser, 'lid', userid)
39
+ set_textfield_by_name(browser, 'pwd', password)
40
+ click_button_by_value(browser, 'Sign In')
41
+ go_to_url(browser, url)
42
+ validate_text(browser, validation)
43
+ end
44
+
45
+ def navigate_to_crm(browser)
46
+ mark_testlevel("#{__method__.to_s.titleize}", 3)
47
+ click_text(browser, 'CRM')
48
+ end
49
+
50
+ def navigate_to_project(browser)
51
+ mark_testlevel("#{__method__.to_s.titleize}", 3)
52
+ click_text(browser, 'Projects')
53
+ end
54
+
55
+ def signout(browser)
56
+ mark_testlevel("#{__method__.to_s.titleize}", 8)
57
+ click_text(browser, /Sign Out/)
58
+ end
59
+
60
+ def create_blank_new_account(browser)
61
+ mark_testlevel("#{__method__.to_s.titleize}", 3)
62
+ click_text(browser, 'New Account')
63
+ validate_text(browser, 'Create Account')
64
+ click_button_by_value(browser, 'Save')
65
+ sleep(1)
66
+ close_popup('Message from webpage')
67
+ end
68
+
69
+ def export_accounts(browser)
70
+ mark_testlevel("#{__method__.to_s.titleize}", 5)
71
+ click_text(browser, 'Setup')
72
+ sleep_for(2)
73
+ click_text(browser, 'Export Data')
74
+ sleep_for(2)
75
+ select_option_by_name_and_option_value(browser, 'module', 'Accounts')
76
+ if @use_sikuli
77
+ run_sikuli_script("exportaccounts")
78
+ close_popup('File Download')
79
+ else
80
+ #click_button_no_wait_by_value(browser, 'Export')
81
+ # Make sure popups are allowed by browser
82
+
83
+ mark_testlevel("#{__method__.to_s.titleize} Download", 4)
84
+ filename = 'Account_Export.cvs'
85
+ filepath = "#{@myRoot}/#{filename}"
86
+ filepath.gsub!('/', '\\')
87
+ message_to_log("#{filepath.to_s}")
88
+ if File.exist?(filepath)
89
+ File.delete(filepath)
90
+ end
91
+ sleep(3)
92
+
93
+ click_button_no_wait_by_value(browser, 'Export')
94
+ sleep_for(5)
95
+ close_popup('Message from webpage', 'Are you sure?')
96
+ sleep_for(1)
97
+
98
+ click_button_no_wait_by_value(browser, 'Export')
99
+ sleep_for(3)
100
+ close_popup('Message from webpage', 'Are you sure?')
101
+ sleep_for(3)
102
+
103
+ save_file1(filepath)
104
+ sleep_for(4)
105
+
106
+ #if popup_exists?(popup, 'File Download')
107
+ # save_file(filepath)
108
+ # click_popup_button('File Download', 'Save')
109
+ # file_download(browser)
110
+ # save_file_orig(filepath)
111
+ # close_popup_by_button_title(popup, 'Close', 'Download Complete')
112
+ #end
113
+ end
114
+ end
115
+
116
+ def import_accounts(browser)
117
+ mark_testlevel("#{__method__.to_s.titleize}", 5)
118
+ #click_class(browser, 'menuOn', 'Accounts')
119
+ click_text(browser, 'Accounts')
120
+ click_text(browser, 'Import Accounts')
121
+ click(browser, :button, :value, 'Import Accounts')
122
+ validate_text(browser, 'Import Accounts')
123
+ #click_button_by_name(browser, 'theFile')
124
+ #file_upload(filepath)
125
+ #click_button_by_class(browser, 'button')
126
+ #select_option_by_name_and_option_value(browser, 'CrmAccount:ACCOUNTNAME', 'Account Name')
127
+ #click_button_by_class(browser, 'button')
128
+ #click_button_by_value(browser, 'Import')
129
+ #validate_no_text(browser, '0', 'No of Records added:')
130
+ end
131
+
132
+ def verify_accounts(browser)
133
+ mark_testlevel("#{__method__.to_s.titleize}", 5)
134
+ click_text(browser, 'Accounts')
135
+ validate_text(browser, '<No Accounts found >')
136
+ #select_option_by_class_and_option_value(browser, 'select', 'My Accounts')
137
+ #sleep(1)
138
+ #select_option_by_class_and_option_value(browser, 'select', 'New This Week')
139
+ #sleep(1)
140
+ #select_option_by_class_and_option_value(browser, 'select', 'New Last Week')
141
+ #sleep(1)
142
+ #select_option_by_class_and_option_value(browser, 'select', 'Unread Accounts')
143
+ #sleep(1)
144
+ end
145
+
146
+ def reports(browser)
147
+ mark_testlevel("#{__method__.to_s.titleize}", 6)
148
+ click_text(browser, 'Reports')
149
+ validate_text(browser, 'Recently Accessed Reports')
150
+ validate_text(browser, '<No Recent Reports Found >')
151
+ end
152
+
153
+ def search_accounts(browser)
154
+ mark_testlevel("#{__method__.to_s.titleize}", 6)
155
+ select_option_by_name_and_option_value(browser, 'searchCategory', 'Accounts')
156
+ set_textfield_by_id(browser, 'searchword', 'Test Account #1')
157
+ click_button_by_value(browser, 'Go')
158
+ sleep(3)
159
+ validate_text(browser, 'Search Results')
160
+ end
161
+
162
+ def clone_account(browser)
163
+ mark_testlevel("#{__method__.to_s.titleize}", 5)
164
+ click_text(browser, 'Home')
165
+ sleep(1)
166
+ validate_text(browser, 'Welcome tester at Software')
167
+ click_text(browser, 'Tester')
168
+ sleep(2)
169
+ validate_text(browser, 'Lead Details')
170
+ validate_text(browser, 'Lead Information')
171
+ click_button_by_name(browser, 'Clone')
172
+ sleep(2)
173
+ validate_text(browser, 'Clone Account')
174
+ click_button_by_value(browser, 'Save')
175
+ end
176
+
177
+ def pagination(browser)
178
+ mark_testlevel("#{__method__.to_s.titleize}", 6)
179
+ click_text(browser, 'Accounts')
180
+ sleep(1)
181
+ click_text(browser, 'A')
182
+ sleep(1)
183
+ click_text(browser, 'B')
184
+ sleep(1)
185
+ click_text(browser, 'C')
186
+ sleep(1)
187
+ click_text(browser, 'D')
188
+ sleep(1)
189
+ click_text(browser, 'E')
190
+ sleep(1)
191
+ click_text(browser, 'F')
192
+ sleep(1)
193
+ end
194
+
195
+ def click_headers(browser)
196
+ mark_testlevel("#{__method__.to_s.titleize}", 6)
197
+ click_text(browser, 'Leads')
198
+ sleep(1)
199
+ click_text(browser, 'Accounts')
200
+ sleep(1)
201
+ click_text(browser, 'Contacts')
202
+ sleep(1)
203
+ click_text(browser, 'Potentials')
204
+ sleep(1)
205
+ click_text(browser, 'Campaigns')
206
+ sleep(1)
207
+ click_text(browser, 'Reports')
208
+ sleep(1)
209
+ click_text(browser, 'Dashboards')
210
+ sleep(1)
211
+ click_text(browser, 'Activities')
212
+ sleep(1)
213
+ click_text(browser, 'Cases')
214
+ sleep(1)
215
+ end
216
+
217
+ def new_lead(browser)
218
+ mark_testlevel("#{__method__.to_s.titleize}", 3)
219
+ click_text(browser, 'Leads')
220
+ sleep(2)
221
+ validate_text(browser, 'Leads: All Open Leads')
222
+ click_button_by_value(browser, 'New Lead ')
223
+ sleep(2)
224
+ validate_text(browser, 'Create Lead')
225
+ select_option_by_name_and_option_value(browser, 'property(saltName)', 'Mr.')
226
+ #browser.select_list(:name, 'property(saltName)').select_value(Mr.)
227
+
228
+ set_textfield_by_name(browser, 'property(Company)', 'Test Zoho Company')
229
+ set_textfield_by_name(browser, 'property(Last Name)', 'Tester')
230
+ set_textfield_by_name(browser, 'property(Phone)', '415-999-9999')
231
+
232
+ select_option_by_name_and_option_value(browser, 'property(Lead Source)', 'Advertisement')
233
+ select_option_by_name_and_option_value(browser, 'property(Industry)', 'ASP')
234
+ select_option_by_name_and_option_value(browser, 'property(Lead Status)', 'Contacted')
235
+ select_option_by_name_and_option_value(browser, 'property(Rating)', 'Active')
236
+
237
+
238
+ browser.image(:title, 'Calculator').click
239
+ sleep(4)
240
+ attach_popup_by_url(browser, "https://crmold.zoho.com/crm/Calc.do?currFld=property(Annual%20Revenue)")
241
+ sleep(3)
242
+ close_modal_ie(browser, 'Calculator')
243
+ set_checkbox_by_name(browser, 'property(Email Opt Out)')
244
+ sleep(2)
245
+ clear_checkbox_by_name(browser, 'property(Email Opt Out)')
246
+
247
+
248
+ set_textfield_by_name(browser, 'property(Street)', '1600 Holloway Avenue') ## Address
249
+ set_textfield_by_name(browser, 'property(State)', 'California')
250
+ set_textfield_by_name(browser, 'property(City)', 'San Francisco')
251
+ set_textfield_by_name(browser, 'property(Zip Code)', '94541')
252
+ set_textfield_by_name(browser, 'property(Country)', 'USA')
253
+
254
+ set_textfield_by_name(browser, 'property(Description)', 'This is a description')
255
+ click_button_by_value(browser, 'Save')
256
+ sleep(2)
257
+ end
258
+
259
+ def find_leads(browser)
260
+ mark_testlevel("#{__method__.to_s.titleize}", 5)
261
+ click_text(browser, 'Leads')
262
+ sleep(1)
263
+ set_textfield_by_name(browser, 'newsearchString', 'Test Zoho Company')
264
+ click_button_by_name(browser, 'Go')
265
+ sleep(2)
266
+ validate_text(browser, 'Test Zoho Company')
267
+ end
268
+
269
+ def leads_delete_message(browser)
270
+ mark_testlevel("#{__method__.to_s.titleize}", 4)
271
+ click_text(browser, 'Leads')
272
+ sleep(1)
273
+ set_checkbox_by_name(browser, 'allcheck')
274
+ sleep(1)
275
+ clear_checkbox_by_name(browser, 'allcheck')
276
+ sleep(1)
277
+ click_button_by_value(browser, 'Delete')
278
+ sleep(1)
279
+ close_popup('Message from webpage')
280
+ end
281
+
282
+ def find_lead_reports(browser) ## Find Lead Reports by Source
283
+ mark_testlevel("#{__method__.to_s.titleize}", 6)
284
+ click_text(browser, 'Reports')
285
+ sleep(2)
286
+ click_text(browser, 'Lead Reports')
287
+ sleep(2)
288
+ click_text(browser, 'Leads By Source')
289
+ sleep(2)
290
+ validate_text(browser, 'Leads By Source')
291
+
292
+ select_option_by_name_and_option_value(browser, 'stdDateFilter', 'today')
293
+ click_button_by_value(browser, 'Apply Filter')
294
+ sleep(2)
295
+ validate_text(browser, 'tester')
296
+ end
297
+
298
+ def create_chart(browser)
299
+ mark_testlevel("#{__method__.to_s.titleize}", 7)
300
+ click_button_by_value(browser, 'Delete Chart')
301
+ sleep(2)
302
+ click_button_by_value(browser, 'Create Chart')
303
+ sleep(2)
304
+ validate_text(browser, 'Create Chart: Leads By Source')
305
+
306
+ browser.frame(:name, 'chartLayer').cell(:text, 'Vertical Bar').click
307
+
308
+ #click_id(browser, 'chart1') ## Vertical Bar chart
309
+ sleep(2)
310
+ click_button_by_value(browser, 'Save')
311
+ sleep(3)
312
+ end
313
+
314
+ def create_campaign(browser)
315
+ mark_testlevel("#{__method__.to_s.titleize}", 7)
316
+ click_text(browser, 'Home')
317
+ sleep(1)
318
+ click_text(browser, 'Create Campaign')
319
+ set_textfield_by_name(browser, 'property(Campaign Name)', 'Zoho Campaign')
320
+ select_option_by_name_and_option_value(browser, 'property(Type)', 'Conference')
321
+ select_option_by_name_and_option_value(browser, 'property(Status)', 'Planning')
322
+ sleep(1)
323
+ set_textfield_by_name(browser, 'property(Start Date)', '03/11/2012')
324
+ set_textfield_by_name(browser, 'property(End Date)', '05/20/2012')
325
+ #browser.button(:onclick, 'showCalc('property(Actual Cost)')'
326
+
327
+ end
328
+
329
+ def create_task(browser)
330
+ mark_testlevel("#{__method__.to_s.titleize}", 8)
331
+ click_text(browser, 'Home')
332
+ sleep(1)
333
+ click_text(browser, 'New Task')
334
+ sleep(2)
335
+ validate_text(browser, 'Create Task')
336
+
337
+ browser.image(:title, 'Subject Name Lookup').click
338
+ sleep(2)
339
+ popup = attach_browser_by_url(browser, /Subject/)
340
+
341
+ sleep(2)
342
+ popup.link(:text, 'Product Demo').click
343
+ validate_textfield_value_by_name(browser, /Subject/, 'Product Demo')
344
+
345
+ set_textfield_by_name(browser, 'property(Due Date)', '03/11/2012')
346
+ select_option_by_name_and_option_value(browser, 'property(leContModSel)', 'Leads')
347
+ sleep(1)
348
+ select_option_by_name_and_option_value(browser, 'property(leContModSel)', 'Contacts')
349
+
350
+ browser.image(:id, 'modNameImg').click
351
+ sleep(2)
352
+ #attach_popup(browser, :title, /Zoho CRM - Account Name Lookup/)
353
+ popup = attach_browser_by_url(browser, "https://crmold.zoho.com/crm/Search.do?searchmodule=Accounts&fldName=modname&fldId=modid&fldLabel=Accounts&fldValue=&user=undefined&condition=undefined")
354
+ sleep(1)
355
+ set_textfield_by_name(popup, 'fldValue', 'Test Account #1')
356
+ click_button_by_value(popup, 'Go')
357
+ popup.link(:text, 'Test Account #1').click
358
+ close_modal_ie(browser, 'Account Name Lookup')
359
+ sleep(2)
360
+
361
+ select_option_by_name_and_option_value(browser, 'property(Status)', 'In Progress')
362
+ select_option_by_name_and_option_value(browser, 'property(Priority)', 'Normal')
363
+ set_textfield_by_name(browser, 'property(Description)', 'This is the task information')
364
+ click_button_by_value(browser, 'Save')
365
+ sleep(3)
366
+ end
367
+
368
+ ########################################################################
369
+ # EVERYTHING BELOW: TEMPORARY OVERRIDES/ADDITIONS NOT YET IN SHAMISEN pmn 12jul1012
370
+ ########################################################################
371
+
372
+ def get_variables(file, login = :role, dbg = true)
373
+ debug_to_log("#{__method__}: file = #{file}")
374
+ debug_to_log("#{__method__}: role = #{login}")
375
+
376
+ @var = Hash.new
377
+ workbook = Excel.new(file)
378
+ data_index = find_sheet_with_name(workbook, 'Data')
379
+ workbook.default_sheet = workbook.sheets[data_index]
380
+ var_col = 0
381
+
382
+ 2.upto(workbook.last_column) do |col|
383
+ scriptName = workbook.cell(1, col)
384
+ if scriptName == @myName
385
+ var_col = col
386
+ break
387
+ end
388
+ end
389
+
390
+ 2.upto(workbook.last_row) do |line|
391
+ name = workbook.cell(line, 'A')
392
+ value = workbook.cell(line, var_col).to_s.strip
393
+ @var[name] = value
394
+ end
395
+
396
+ @var.keys.sort.each do |name|
397
+ message_tolog("@var #{name}: '#{@var[name]}'")
398
+ end if dbg
399
+
400
+ @login = Hash.new
401
+ login_col = 0
402
+ role_col = 0
403
+ userid_col = 0
404
+ password_col = 0
405
+ url_col = 0
406
+ name_col = 0
407
+ role_index = find_sheet_with_name(workbook, 'Login')
408
+ if role_index >= 0
409
+ workbook.default_sheet = workbook.sheets[role_index]
410
+
411
+ 1.upto(workbook.last_column) do |col|
412
+ a_cell = workbook.cell(1, col)
413
+ case a_cell
414
+ when @myName
415
+ login_col = col
416
+ break
417
+ when 'role'
418
+ role_col = col
419
+ when 'userid'
420
+ userid_col = col
421
+ when 'password'
422
+ password_col = col
423
+ when 'url'
424
+ url_col = col
425
+ when 'name'
426
+ name_col = col
427
+ end
428
+ end
429
+
430
+ 2.upto(workbook.last_row) do |line|
431
+ role = workbook.cell(line, role_col)
432
+ userid = workbook.cell(line, userid_col)
433
+ password = workbook.cell(line, password_col)
434
+ url = workbook.cell(line, url_col)
435
+ username = workbook.cell(line, name_col)
436
+ enabled = workbook.cell(line, login_col).to_s
437
+
438
+ case login
439
+ when :id
440
+ key = userid
441
+ when :role
442
+ key = role
443
+ else
444
+ key = role
445
+ end
446
+
447
+ @login[key] = Hash.new
448
+ @login[key]['role'] = role
449
+ @login[key]['userid'] = userid
450
+ @login[key]['password'] = password
451
+ @login[key]['url'] = url
452
+ @login[key]['name'] = username
453
+ @login[key]['enabled'] = enabled
454
+
455
+ end
456
+
457
+ @login.keys.sort.each do |key|
458
+ message_tolog("@login (by #{login}): #{key}=>'#{@login[key].to_yaml}'")
459
+ end if dbg
460
+ end
461
+
462
+ rescue
463
+ fatal_to_log("#{__method__}: '#{$!}'")
464
+ end
465
+
466
+ def find_sheet_with_name(workbook, sheet_name)
467
+ sheets = workbook.sheets
468
+ idx = 0
469
+ found = false
470
+ sheets.each do |s|
471
+ if s == sheet_name
472
+ found = true
473
+ break
474
+ end
475
+ idx += 1
476
+ end
477
+ if found
478
+ idx
479
+ else
480
+ -1
481
+ end
482
+ end
483
+
484
+ end
Binary file