-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtestcases_customize.py
535 lines (445 loc) · 22.3 KB
/
testcases_customize.py
1
2
3
4
5
6
7
8
9
10
11
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
#=======================================================================
#
# CUSTOMIZE DESIGN TESTS
#
#=======================================================================
#
# Includes the following test cases:
# 1. TestCase_EditSiteTitle_303
# 2. TestCase_MaxLengthSiteTitle_304
# 3. TestCase_EditSiteTagline_305
# 4. TestCase_MaxLengthSiteTagline_306
# 5. TestCase_EditAboutUs_307
# TestCase_ChangeSiteSettings_303
# 2. TestCase_ChangeOrganization_253
# 3. TestCase_UploadLogo_243
# 4. TestCase_UploadBackground_244
# 5. TestCase_DeleteBackground_245
# 6. TestCase_AddCustomCSS_251
# 7. TestCase_DisplaySubmitVideo_249
# 8. TestCase_CheckRequireLoginToSubmitVideo_250
from selenium import selenium
import unittest, time, re, loginlogout, sitesettings, testvars
import mclib
import sys
# ----------------------------------------------------------------------
class TestCase_EditSiteTitle_303(unittest.TestCase):
# Open the desired browser and set up the test
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", testvars.MCTestVariables["Port"], testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
# The user actions executed in the test scenario
def EditSiteTitle_303(self,sel,theme):
print ""
print "Running EditSiteTitle test... with theme No."+str(theme)
# Change site settings
newtitle = "Dalmatia in Theme "+str(theme)
sitesettings.EditSiteTitle(self,sel,theme,newtitle)
def test_EditSiteTitle_303(self):
sel = self.selenium
# Log in as Admin
loginlogout.LogInAsAdmin(self,sel)
# Repeat for each theme from No.1 to No.4
for theme in range(1,2):
sitesettings.ChangeTheme(self,sel,theme)
TestCase_EditSiteTitle_303.EditSiteTitle_303(self,sel,theme)
# Close the browser, log errors, perform cleanup
def tearDown(self):
self.selenium.stop()
# the command on the previous line should close the browser
self.assertEqual([], self.verificationErrors)
class TestCase_MaxLengthSiteTitle_304(unittest.TestCase):
# Open the desired browser and set up the test
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", testvars.MCTestVariables["Port"], testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
# The user actions executed in the test scenario
def MaxLengthSiteTitle_304(self,sel,theme, valid_title):
print ""
print "Running MaxLengthSiteTitle test... with theme No."+str(theme)
# Change site settings
sitesettings.EditSiteTitle(self,sel,theme,valid_title)
def test_MaxLengthSiteTitle_304(self):
sel = self.selenium
# Log in as Admin
loginlogout.LogInAsAdmin(self,sel)
# Repeat for each theme from No.1 to No.4
for theme in range(1,2):
sitesettings.ChangeTheme(self,sel,theme)
# Create a title with a timestamp
timestamp = time.strftime("%d-%m-%Y %H:%M:%S", time.localtime())
valid_title = 'MiroCommunity Title-SeleniumRC-' + timestamp
# If necessary, extend the title to match the maximum permitted length
while len(valid_title) < testvars.MCTestVariables["MaxSiteTitle"]:
valid_title = valid_title+'X'
TestCase_MaxLengthSiteTitle_304.MaxLengthSiteTitle_304(self,sel,theme,valid_title)
# Attempt to enter max+1 characters into Site Title field
sitesettings.NavigateToSettingsPage(self,sel)
invalid_title = valid_title + str(theme)
if sel.is_element_present("id_title")==False:
mclib.AppendErrorMessage(self,sel,"Site Title edit field not found")
else:
print ""
print ""
print "Attempting to type an invalid long string into Site Title field..."
sel.click("id_title")
sel.type("id_title", invalid_title)
typed_value = sel.get_value("id_title")
if typed_value==invalid_title:
mclib.AppendErrorMessage(self,sel,"Site Title accepts strings exceeding the maximum length")
else:
print "Cannot type overly long strings to Site Title field"
print "Attempted to type: "+invalid_title
print "-- Actually typed: "+typed_value
print "OK"
# Close the browser, log errors, perform cleanup
def tearDown(self):
self.selenium.stop()
# the command on the previous line should close the browser
self.assertEqual([], self.verificationErrors)
class TestCase_EditSiteTagline_305(unittest.TestCase):
# Open the desired browser and set up the test
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", testvars.MCTestVariables["Port"], testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
# The user actions executed in the test scenario
def EditSiteTagline_305(self,sel,theme):
print ""
print "Running EditSiteTagline test... with theme No."+str(theme)
# Change site settings
timestamp = time.strftime("%d-%m-%Y %H:%M:%S", time.localtime())
newtagline = 'Create your own site to share videos with friends-' + timestamp + '. Theme '+str(theme)
sitesettings.EditSiteTagline(self,sel,theme,newtagline)
def test_EditSiteTagline_305(self):
sel = self.selenium
# Log in as Admin
loginlogout.LogInAsAdmin(self,sel)
# Repeat for each theme from No.1 to No.4
for theme in range(1,2):
sitesettings.ChangeTheme(self,sel,theme)
TestCase_EditSiteTagline_305.EditSiteTagline_305(self,sel,theme)
# Close the browser, log errors, perform cleanup
def tearDown(self):
self.selenium.stop()
# the command on the previous line should close the browser
self.assertEqual([], self.verificationErrors)
class TestCase_MaxLengthSiteTagline_306(unittest.TestCase):
# Open the desired browser and set up the test
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", testvars.MCTestVariables["Port"], testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
# The user actions executed in the test scenario
def MaxLengthSiteTagline_306(self,sel,theme, valid_tagline):
print ""
print "Running MaxLengthSiteTagline test... with theme No."+str(theme)
# Change site settings
sitesettings.EditSiteTagline(self,sel,theme,valid_tagline)
def test_MaxLengthSiteTagline_306(self):
sel = self.selenium
# Log in as Admin
loginlogout.LogInAsAdmin(self,sel)
# Repeat for each theme from No.1 to No.4
for theme in range(1,2):
sitesettings.ChangeTheme(self,sel,theme)
# Create a title with a timestamp
valid_tagline = 'MC Theme' + str(theme)+' 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567890'
# If necessary, extend the title to match the maximum permitted length
while len(valid_tagline) < testvars.MCTestVariables["MaxSiteTagline"]:
valid_tagline = valid_tagline+'X'
TestCase_MaxLengthSiteTagline_306.MaxLengthSiteTagline_306(self,sel,theme,valid_tagline)
# Attempt to enter max+1 characters into Site Title field
sitesettings.NavigateToSettingsPage(self,sel)
invalid_tagline = valid_tagline + str(theme)
if sel.is_element_present("id_tagline")==False:
mclib.AppendErrorMessage(self,sel,"Site Tagline edit field not found")
else:
print ""
print ""
print "Attempting to type an invalid long string into Site Tagline field..."
sel.click("id_tagline")
sel.type("id_tagline", invalid_tagline)
typed_value = sel.get_value("id_tagline")
if typed_value==invalid_tagline:
mclib.AppendErrorMessage(self,sel,"Site Tagline accepts strings exceeding the maximum length")
else:
print "Cannot type overly long strings to Site Tagline field"
print "Attempted to type: "+invalid_tagline
print "-- Actually typed: "+typed_value
print "OK"
# Close the browser, log errors, perform cleanup
def tearDown(self):
self.selenium.stop()
# the command on the previous line should close the browser
self.assertEqual([], self.verificationErrors)
class TestCase_EditAboutUs_307(unittest.TestCase):
# Open the desired browser and set up the test
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", testvars.MCTestVariables["Port"], testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
# The user actions executed in the test scenario
def EditAboutUs_307(self,sel,theme):
print ""
print "Running EditAboutUs test... with theme No."+str(theme)
# Change site settings
timestamp = time.strftime("%d-%m-%Y %H:%M:%S", time.localtime())
newabouttext = 'Miro was first launched in 2005 as DTV, with the name being changed to Democracy Player in 2006.' + timestamp
sitesettings.EditAboutUs(self,sel,theme,newabouttext)
def test_EditAboutUs_307(self):
sel = self.selenium
# Log in as Admin
loginlogout.LogInAsAdmin(self,sel)
# Repeat for each theme from No.1 to No.4
for theme in range(1,2):
sitesettings.ChangeTheme(self,sel,theme)
TestCase_EditAboutUs_307.EditAboutUs_307(self,sel,theme)
# Close the browser, log errors, perform cleanup
def tearDown(self):
self.selenium.stop()
# the command on the previous line should close the browser
self.assertEqual([], self.verificationErrors)
class TestCase_AboutUsHTML_309(unittest.TestCase):
# Open the desired browser and set up the test
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", testvars.MCTestVariables["Port"], testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
# The user actions executed in the test scenario
def AboutUsHTML_309(self,sel,theme, newabouttext):
print ""
print "Running AboutUsHTML test... with theme No."+str(theme)
# Change site settings
sitesettings.EditAboutUs(self,sel,theme,newabouttext)
def test_AboutUsHTML_309(self):
sel = self.selenium
# Log in as Admin
loginlogout.LogInAsAdmin(self,sel)
# Repeat for each theme from No.1 to No.4
for theme in range(1,2):
sitesettings.ChangeTheme(self,sel,theme)
# Create a title with a timestamp
timestamp = time.strftime("%d-%m-%Y %H:%M:%S", time.localtime())
newabouttext = timestamp+' This is the testing site for Miro Community <b style="COLOR: red">Title in bold</b> <h5 >Title in h5</h5> <h8>Title in h8</h8>'
# If necessary, extend the title to match the maximum permitted length
TestCase_AboutUsHTML_309.AboutUsHTML_309(self,sel,theme,newabouttext)
# Close the browser, log errors, perform cleanup
def tearDown(self):
self.selenium.stop()
# the command on the previous line should close the browser
self.assertEqual([], self.verificationErrors)
class TestCase_ChangeSiteSettings_303(unittest.TestCase):
# Open the desired browser and set up the test
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", testvars.MCTestVariables["Port"], testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
# The user actions executed in the test scenario
def ChangeSiteSettings(self,sel,theme):
print ""
print "Running ChangeSiteSettings test... with theme No."+str(theme)
# Change site settings
sitesettings.ModifySiteSettings(self,sel,theme)
def test_ChangeSiteSettings_303(self):
sel = self.selenium
# Log in as Admin
loginlogout.LogInAsAdmin(self,sel)
# Repeat for each theme from No.1 to No.4
for theme in range(1,2):
sitesettings.ChangeTheme(self,sel,theme)
TestCase_ChangeSiteSettings_303.ChangeSiteSettings(self,sel,theme)
# Close the browser, log errors, perform cleanup
def tearDown(self):
self.selenium.stop()
# the command on the previous line should close the browser
self.assertEqual([], self.verificationErrors)
class TestCase_ChangeOrganization_253(unittest.TestCase):
# Open the desired browser and set up the test
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", testvars.MCTestVariables["Port"], testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
# The user actions executed in the test scenario
def ChangeOrganizationSettings(self,sel,theme):
print "Running ChangeOrganizationSettings test... with theme No."+str(theme)
# Change site settings
sitesettings.ModifyOrganizationSettings(self,sel,theme)
def test_ChangeOrganizationSettings_253(self):
sel = self.selenium
# Log in as Admin
loginlogout.LogInAsAdmin(self,sel)
# Repeat for each theme from No.1 to No.4
for theme in range(1,2):
sitesettings.ChangeTheme(self,sel,theme)
# Change site settings
TestCase_ChangeOrganization_253.ChangeOrganizationSettings(self,sel,theme)
# Close the browser, log errors, perform cleanup
def tearDown(self):
self.selenium.stop()
# the command on the previous line should close the browser
self.assertEqual([], self.verificationErrors)
class TestCase_UploadLogo_243(unittest.TestCase):
# Open the desired browser and set up the test
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", testvars.MCTestVariables["Port"], testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
# The user actions executed in the test scenario
def UploadLogo(self,sel,theme):
print ""
print "Running UploadLogo test... with theme No."+str(theme)
newlogo = "dalmatia1.jpg"
print "Uploading file: "+newlogo
# Upload new site logo
sitesettings.UploadSiteLogo(self,sel,theme,newlogo)
# Repeat for another file. This is done to ensure that logo actually changes at each test run
newlogo = "dalmatia2.jpg"
print "Uploading file: "+newlogo
# Upload new site logo
sitesettings.UploadSiteLogo(self,sel,theme,newlogo)
def test_UploadLogo_243(self):
sel = self.selenium
# Log in as Admin
loginlogout.LogInAsAdmin(self,sel)
# Repeat for each theme from No.1 to No.4
for theme in range(1,2):
sitesettings.ChangeTheme(self,sel,theme)
TestCase_UploadLogo_243.UploadLogo(self,sel,theme)
# Close the browser, log errors, perform cleanup
def tearDown(self):
self.selenium.stop()
# the command on the previous line should close the browser
self.assertEqual([], self.verificationErrors)
class TestCase_UploadBackground_244(unittest.TestCase):
# Open the desired browser and set up the test
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", testvars.MCTestVariables["Port"], testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
# The user actions executed in the test scenario
def UploadBackground(self,sel,theme):
print ""
print "Running UploadBackground test... with theme No."+str(theme)
newbkgr = "background4.jpg"
print "Uploading file: "+newbkgr
# Upload new background image
sitesettings.UploadBackgroundImage(self,sel,theme,newbkgr)
def test_UploadBackground_244(self):
sel = self.selenium
# Log in as Admin
loginlogout.LogInAsAdmin(self,sel)
# Repeat for each theme from No.1 to No.4
for theme in range(1,2):
sitesettings.ChangeTheme(self,sel,theme)
TestCase_UploadBackground_244.UploadBackground(self,sel,theme)
# Close the browser, log errors, perform cleanup
def tearDown(self):
self.selenium.stop()
# the command on the previous line should close the browser
self.assertEqual([], self.verificationErrors)
class TestCase_DeleteBackground_245(unittest.TestCase):
# Open the desired browser and set up the test
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", testvars.MCTestVariables["Port"], testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
# The user actions executed in the test scenario
def DeleteBackground(self,sel):
print ""
print "Running DeleteBackground test..."
# Delete background
sitesettings.DeleteBackgroundImage(self,sel)
def test_DeleteBackground_245(self):
sel = self.selenium
# Log in as Admin
loginlogout.LogInAsAdmin(self,sel)
TestCase_DeleteBackground_245.DeleteBackground(self,sel)
# Close the browser, log errors, perform cleanup
def tearDown(self):
self.selenium.stop()
# the command on the previous line should close the browser
self.assertEqual([], self.verificationErrors)
class TestCase_AddCustomCSS_251(unittest.TestCase):
# Open the desired browser and set up the test
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", testvars.MCTestVariables["Port"], testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
# The user actions executed in the test scenario
def AddCustomCSS(self,sel):
print ""
print "Running AddCustomCSS test..."
cssString = "body\n{\nbackground-color:#d0e4fe;\n}\nh1\n{\ncolor:orange;\ntext-align:center;\n}\np\n{\nfont-family:\"Times New Roman\";\nfont-size:20px;\n}"
print "Adding CSS: "+cssString
# Add custom CSS
sitesettings.AddCustomCSS(self,sel,cssString)
print "Deleting custom CSS"
sitesettings.DeleteCustomCSS(self,sel)
def test_AddCustomCSS_251(self):
sel = self.selenium
# Log in as Admin
loginlogout.LogInAsAdmin(self,sel)
TestCase_AddCustomCSS_251.AddCustomCSS(self,sel)
# Close the browser, log errors, perform cleanup
def tearDown(self):
self.selenium.stop()
# the command on the previous line should close the browser
self.assertEqual([], self.verificationErrors)
class TestCase_DisplaySubmitVideo_249(unittest.TestCase):
# Open the desired browser and set up the test
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", testvars.MCTestVariables["Port"], testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
# The user actions executed in the test scenario
def DisplaySubmitVideo(self,sel,theme):
print ""
print "Running DisplaySubmitVideo test... with theme No."+str(theme)
# Check Display Submit a Video check box
sitesettings.DisplaySubmitVideo(self,sel,theme)
# Uncheck Display Submit a Video check box
sitesettings.HideSubmitVideo(self,sel,theme)
def test_DisplaySubmitVideo_249(self):
sel = self.selenium
# Log in as Admin
loginlogout.LogInAsAdmin(self,sel)
# Repeat for each theme from No.1 to No.4
for theme in range(1,2):
sitesettings.ChangeTheme(self,sel,theme)
TestCase_DisplaySubmitVideo_249.DisplaySubmitVideo(self,sel,theme)
# Close the browser, log errors, perform cleanup
def tearDown(self):
self.selenium.stop()
# the command on the previous line should close the browser
self.assertEqual([], self.verificationErrors)
class TestCase_CheckRequireLoginToSubmitVideo_250(unittest.TestCase):
# Open the desired browser and set up the test
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", testvars.MCTestVariables["Port"], testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
# The user actions executed in the test scenario
def CheckRequireLoginToSubmitVideo(self,sel,theme):
print "Running CheckRequireLoginToSubmitVideo test... with theme No."+str(theme)
# Change site settings
sitesettings.CheckRequireLoginToSubmitVideo(self,sel,theme)
def test_CheckRequireLoginToSubmitVideo_250(self):
sel = self.selenium
# Repeat for each theme from No.1 to No.4
for theme in range(1,2):
print ""
print ""
# Log in as Admin
loginlogout.LogInAsAdmin(self,sel)
# Change theme
sitesettings.ChangeTheme(self,sel,theme)
# Change site settings
TestCase_CheckRequireLoginToSubmitVideo_250.CheckRequireLoginToSubmitVideo(self,sel,theme)
# Close the browser, log errors, perform cleanup
def tearDown(self):
self.selenium.stop()
# the command on the previous line should close the browser
self.assertEqual([], self.verificationErrors)