forked from pculture/mirocommunity-testing
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestcases_bulkedit.py
1167 lines (894 loc) · 45.3 KB
/
testcases_bulkedit.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
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#=======================================================================
#
# COMMENTS TESTS
#
#=======================================================================
#
# Includes the following test cases:
# 1. testcase_BulkEdit_EditAndDelete
# 2. testcase_BulkEdit_DeleteSingleVideo
# 3. testcase_BulkEdit_EditSingleVideo
# 4. testcase_BulkEdit_UnapproveCurrent
# 5. testcase_BulkEdit_UnapproveFeatured
# 6. testcase_BulkEdit_SortByTitle
# 7. testcase_BulkEdit_SortBySource
# 8. testcase_BulkEdit_SortByDatePublished
# 9. testcase_BulkEdit_SortByDateImported
from selenium import selenium
import unittest, time, re, loginlogout, sitesettings, categories, testvars, random
import sys
global initialCategories
initialCategories = [""]
# ----------------------------------------------------------------------
#------ Variables ---------
global gLoginButtonInLoginPopUpWindow
gLoginButtonInLoginPopUpWindow = "//input[@value='Log In']"
global gViewAdmin
gViewAdmin = 'link=View Admin'
global gLinkLogin
gLinkLogin = 'link=Login'
global gBulkEditOnAdminPage
gBulkEditOnAdminPage = "//div[@id='admin_subnav']/ul/li[3]/a/span"
global gCategoriesOnAdminPage
gCategoriesOnAdminPage = "XPath=id('admin_subnav')/ul/li[4]/a/span"
global gReviewQueueOnAdminPage
gReviewQueueOnAdminPage = "XPath=id('admin_subnav')/ul/li[1]/a/span"
global gSearchEditBoxOnBulkEditPage
gSearchEditBoxOnBulkEditPage = "XPath=id('labels')/form[1]/input"
global gSearchButtonOnBulkEditPage
gSearchButtonOnBulkEditPage = "//button[span='Search']"
global gSubmitVideoButtonOnAdminPage
gSubmitVideoButtonOnAdminPage = "XPath=id('admin_subnav')/ul/li[5]/a/span"
global gSubmitButtonOnSubmitVideoPage
gSubmitButtonOnSubmitVideoPage = "XPath=id('submit_video')/table/tbody/tr[2]/td/input"
global gSubmitButtonOnSubmitVideoPage2
gSubmitButtonOnSubmitVideoPage2 = "XPath=id('submit_video')/table/tbody/tr[3]/td/input"
global gUrlEditFieldOnSubmitVideoPage
gUrlEditFieldOnSubmitVideoPage = "XPath=id('id_url')"
global gCategoryNameEditField
gCategoryNameEditField = "XPath=id('id_name')"
global gCategorySlugEditField
gCategorySlugEditField = "XPath=id('id_slug')"
global gCategoryName
gCategoryName = "BulkEditTestCategory"
global gAddCategoryButton
gAddCategoryButton = "XPath=id('label_sidebar')/button"
global gAddCategoryButtonOnCategoryPage
gAddCategoryButtonOnCategoryPage = "XPath=id('content')/a/span"
global gCloseAddCategoryWindowButton
gCloseAddCategoryWindowButton = "XPath=id('label_sidebar')/div[1]"
global gVideo1Url
gVideo1Url = 'http://www.youtube.com/watch?v=be-BoM-WokY'
global gVideo2Url
gVideo2Url = 'http://www.youtube.com/watch?v=-5OmdTaPzd8'
global gVideosLabel
gVideosLabel = "Judo"
global gToggleAll
gToggleAll = "toggle_all"
global gApplyButton
gApplyButton = "//button[@type='button']"
#----
global gActionSelector
gActionSelector = "bulk_action_selector"
global gDeleteOption
gDeleteOption = "label=Delete"
global gEditOption
gEditOption = "label=Edit"
global gFeatureOption
gFeatureOption = "label=Feature"
global gUnfeatureOption
gUnfeatureOption = "label=Unfeature"
global gUnapproveOption
gUnapproveOption = "label=Unapprove"
#----
global gFilterSelector
gFilterSelector = "filter"
global gCurrentFilterOption
gCurrentFilterOption = "label=Current Videos"
global gFeaturedFilterOption
gFeaturedFilterOption = "label=Featured Videos"
#----
global gEditTitle
gEditTitle = "BulkEditTestTitleJudo"
global gEditDate
gEditDate = "1666-06-11 00:00:00"
global gEditDescription
gEditDescription = "BulkEditTestDescription"
global gEditTag
gEditTag = "bulkedittesttag"
#---
global gEditCategoryXPath
gEditCategoryXPath = "//li/label[span='BulkEditTestCategory']/input[@name='form-2-categories']"
global gEditUserXPath
gEditUserXPath = "//li/label[span='BulkEditTestUser']/input[@name='form-2-authors']"
global gEditPageTitleEditField
gEditPageTitleEditField = "XPath=id('id_form-2-name')"
global gEditPageDateEditField
gEditPageDateEditField = "XPath=id('id_form-2-when_published')"
global gEditPageDescriptionEditField
gEditPageDescriptionEditField = "XPath=id('id_form-2-description')"
global gEditPageTagsEditField
gEditPageTagsEditField = "XPath=id('id_form-2-tags')"
#---
global gEditCategoryXPathSingleVideo
gEditCategoryXPathSingleVideo = "//li/label[span='BulkEditTestCategory']/input[@name='form-0-categories']"
global gEditUserXPathSingleVideo
gEditUserXPathSingleVideo = "//li/label[span='BulkEditTestUser']/input[@name='form-0-authors']"
global gEditPageTitleEditFieldSingleVideo
gEditPageTitleEditFieldSingleVideo = "XPath=id('id_form-0-name')"
global gEditPageDateEditFieldSingleVideo
gEditPageDateEditFieldSingleVideo = "XPath=id('id_form-0-when_published')"
global gEditPageDescriptionEditFieldSingleVideo
gEditPageDescriptionEditFieldSingleVideo = "XPath=id('id_form-0-description')"
global gEditPageTagsEditFieldSingleVideo
gEditPageTagsEditFieldSingleVideo = "XPath=id('id_form-0-tags')"
#---
global gVideosSectionOnAdminPage
gVideosSectionOnAdminPage = "XPath=id('admin_nav')/li[1]/a"
global gUsersSectionOnAdminPage
gUsersSectionOnAdminPage = "XPath=id('admin_nav')/li[3]/a"
#---
global gAddUserButtonOnUsersPage
gAddUserButtonOnUsersPage = "XPath=id('label_sidebar')/a/span"
global gAddUserButtonInAddUserWindow
gAddUserButtonInAddUserWindow = "XPath=id('add_user')/form/button"
global gUserNameEditBoxInAddUserWindow
gUserNameEditBoxInAddUserWindow = "XPath=id('id_username')"
global gUserRadioButtonInAddUserWindow
gUserRadioButtonInAddUserWindow = "XPath=id('id_role_0')"
global gPasswordEditBoxInAddUserWindow
gPasswordEditBoxInAddUserWindow = "XPath=id('id_password_f')"
global gConfirmPasswordEditBoxInAddUserWindow
gConfirmPasswordEditBoxInAddUserWindow = "XPath=id('id_password_f2')"
global gBulkEditUserName
gBulkEditUserName = "BulkEditTestUser"
global gBulkEditUserPassword
gBulkEditUserPassword = "password"
global gSaveChangesButtonInEditWindow
gSaveChangesButtonInEditWindow = "XPath=id('massedit')/button"
global gSaveChangesButtonInEditWindowSingleVideo
gSaveChangesButtonInEditWindowSingleVideo = "XPath=id('labels')/form[2]/table/tbody/tr[1]/td[1]/div/button"
global gLinkToViewFirstVideo
gLinkToViewFirstVideo = "XPath=id('labels')/form[2]/table/tbody/tr[1]/td[2]/div/a[3]"
global gLinkToViewSecondVideo
gLinkToViewSecondVideo = "XPath=id('labels')/form[2]/table/tbody/tr[2]/td[2]/div/a[3]"
global gTitlePathOnViewVideoPage
gTitlePathOnViewVideoPage = "XPath=id('main')/div[1]/div/div/div[1]/h2[contains(.,'"
global gUserPathOnViewVideoPage
gUserPathOnViewVideoPage = "XPath=id('main')/div[3]/div/div[1]/a[contains(.,'"
global gDescriptionPathOnViewVideoPage
gDescriptionPathOnViewVideoPage = "XPath=id('main')/div[6]/div[1]/div[contains(.,'"
global gCategoryPathOnViewVideoPage
gCategoryPathOnViewVideoPage = "XPath=id('tags')/ul/li[1]/div/div[1]/div/ul/li/a[contains(.,'"
global gTagsPathOnViewVideoPage
gTagsPathOnViewVideoPage = "XPath=id('tags')/ul/li[2]/div/div[1]/div/ul/li/a[contains(.,'"
global gFirstVideoTitlePathOnBulkEditPage
gFirstVideoTitlePathOnBulkEditPage = "XPath=id('labels')/form[2]/table/tbody/tr[1]/td[2]/span[contains(.,'"
global gSecondVideoTitlePathOnBulkEditPage
gSecondVideoTitlePathOnBulkEditPage = "XPath=id('labels')/form[2]/table/tbody/tr[1]/td[2]/span[contains(.,'"
global gFirstVideoEditLink
gFirstVideoEditLink = "XPath=id('labels')/form[2]/table/tbody/tr[1]/td[2]/div/a[1]"
global gFirstVideoDeleteLink
gFirstVideoDeleteLink = "XPath=id('labels')/form[2]/table/tbody/tr[1]/td[2]/div/a[2]"
global gClearQueueButtonOnReviewQueuePage
gClearQueueButtonOnReviewQueuePage = "XPath=id('content')/a[3]/span"
global gYesClearQueueButton
gYesClearQueueButton = "XPath=id('content')/form/button"
#-----
global gVideoPathOnBulkEditPage
gVideoPathOnBulkEditPage = "XPath=id('labels')/form[2]/table/tbody/tr/td[2]/span[contains(.,'"
global gFirstVideoOriginalName
gFirstVideoOriginalName = "best of judo"
global gSecondVideoOriginalName
gSecondVideoOriginalName = "legends of judo"
#-----
global gVideoTitleOnBulkEditPagePart1
gVideoTitleOnBulkEditPagePart1 = "XPath=id('labels')/form[2]/table/tbody/tr["
global gVideoTitleOnBulkEditPagePart2
gVideoTitleOnBulkEditPagePart2 = "]/td[2]/span"
global gSourceTitleOnBulkEditPagePart1
gSourceTitleOnBulkEditPagePart1 = "XPath=id('labels')/form[2]/table/tbody/tr["
global gSourceTitleOnBulkEditPagePart2
gSourceTitleOnBulkEditPagePart2 = "]/td[3]"
global gDatePublishedTitleOnBulkEditPagePart1
gDatePublishedTitleOnBulkEditPagePart1 = "XPath=id('labels')/form[2]/table/tbody/tr["
global gDatePublishedTitleOnBulkEditPagePart2
gDatePublishedTitleOnBulkEditPagePart2 = "]/td[5]/span"
global gDateImportedTitleOnBulkEditPagePart1
gDateImportedTitleOnBulkEditPagePart1 = "XPath=id('labels')/form[2]/table/tbody/tr["
global gDateImportedTitleOnBulkEditPagePart2
gDateImportedTitleOnBulkEditPagePart2 = "]/td[6]/span"
global gPageLinkPart1
gPageLinkPart1 = "XPath=id('labels')/form[2]/div[3]/ul/li["
global gPageLinkPart2
gPageLinkPart2 = "]/a/span"
global gSortByVideoTitleLink
gSortByVideoTitleLink = "XPath=id('labels')/form[2]/table/thead/tr/th[2]/a"
global gSortBySource
gSortBySource = "XPath=id('labels')/form[2]/table/thead/tr/th[3]/a"
global gSortByDatePublished
gSortByDatePublished = "XPath=id('labels')/form[2]/table/thead/tr/th[5]/a"
global gSortByDateImported
gSortByDateImported = "XPath=id('labels')/form[2]/table/thead/tr/th[6]/a"
#-----
global gSeleniumServerPort
gSeleniumServerPort = testvars.MCTestVariables["Port"]
global gTimeOut
gTimeOut = 20
#------ Functions --------
def WaitUntilTextOnTheScreen(sel, text, inTime):
ltime = 0
while (ltime < inTime):
if sel.is_text_present(text):
return True
time.sleep(1)
ltime = ltime + 1
return False
def WaitUntilElementOnTheScreen(sel, inElement, inTime):
ltime = 0
while (ltime < inTime):
if sel.is_element_present(inElement):
return True
time.sleep(1)
ltime = ltime + 1
return False
#function which performs login with given Login and Password
def LogIn(sel, Login, Password):
sel.open("/")
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
sel.click(gLinkLogin)
if (not WaitUntilElementOnTheScreen(sel, gLoginButtonInLoginPopUpWindow, gTimeOut)):
return False
sel.window_maximize()
sel.type("id_username", Login)
sel.type("id_password", "")
sel.type("id_password", Password)
sel.click(gLoginButtonInLoginPopUpWindow)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
return True
#as setUp() and tearDown() are the same for all test cases we have a good reason to inlude them into one base class
class testcase_BaseTestCase(unittest.TestCase):
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", gSeleniumServerPort, testvars.MCTestVariables["Browser"], testvars.MCTestVariables["TestSite"])
self.selenium.start()
def test_case(self):
return 1
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
#class which contains some functions that are going to be used only for testing 'Bulk Edit'
class testcase_BaseClassForBulkEdit(testcase_BaseTestCase):
#Logins as Admin and goes to View Admin page
def LoginAsAdminSetThemeGoToViewAdmin(self):
sel = self.selenium
LogIn(sel, testvars.MCTestVariables["AdminLogin"], testvars.MCTestVariables["AdminPassword"])
sel.open(testvars.MCTestVariables["ListThemeLink"])
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
sel.click(gVideosSectionOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
#Submits video with given URL, works if video was submitted before
def SubmitVideo(self, in_VideoUrl):
sel = self.selenium
sel.click(gSubmitVideoButtonOnAdminPage)
if (not WaitUntilElementOnTheScreen(sel, gSubmitButtonOnSubmitVideoPage, gTimeOut)):
return False
sel.type(gUrlEditFieldOnSubmitVideoPage, in_VideoUrl)
sel.click(gSubmitButtonOnSubmitVideoPage)
time.sleep(5)
if sel.is_element_present(gSubmitButtonOnSubmitVideoPage2):
sel.click(gSubmitButtonOnSubmitVideoPage2)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
else:
WaitUntilElementOnTheScreen(sel, gViewAdmin, gTimeOut)
sel.click(gViewAdmin)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
#Searches videos with 'gVideosLabel' and deletes them
def DeleteVideos(self):
sel = self.selenium
sel.click(gBulkEditOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
sel.type(gSearchEditBoxOnBulkEditPage, gVideosLabel)
sel.click(gSearchButtonOnBulkEditPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
sel.click(gToggleAll)
sel.select(gActionSelector, gDeleteOption)
sel.click(gApplyButton)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
#Adds new category with name defined in 'gCategoryName', works if category was added before
def AddCategory(self):
sel = self.selenium
sel.click(gCategoriesOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
sel.click(gAddCategoryButtonOnCategoryPage)
WaitUntilElementOnTheScreen(sel, gAddCategoryButton, gTimeOut)
time.sleep(2)
sel.type(gCategoryNameEditField, "")
sel.type(gCategoryNameEditField, gCategoryName)
sel.type(gCategorySlugEditField, "")
sel.type(gCategorySlugEditField, gCategoryName)
sel.click(gAddCategoryButton)
time.sleep(5)
if sel.is_element_present(gCategoryNameEditField):
sel.click(gCloseAddCategoryWindowButton)
#Adds new user with name defined in 'gBulkEditUserName', works if user was added before
def AddUser(self):
sel = self.selenium
sel.click(gUsersSectionOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
sel.click(gAddUserButtonOnUsersPage)
WaitUntilElementOnTheScreen(sel, gUserRadioButtonInAddUserWindow, gTimeOut)
sel.type(gUserNameEditBoxInAddUserWindow, gBulkEditUserName)
sel.click(gUserRadioButtonInAddUserWindow)
sel.type(gPasswordEditBoxInAddUserWindow, gBulkEditUserPassword)
sel.type(gConfirmPasswordEditBoxInAddUserWindow, gBulkEditUserPassword)
sel.click(gAddUserButtonInAddUserWindow)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
sel.click(gVideosSectionOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
#Checks if changes that were made during editing of bulk of videos were saved and they are correct
def checkChanges(self, in_ViewLink, in_CheckTags):
sel = self.selenium
sel.click(in_ViewLink)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
#XPath=id('main')/div[1]/div/div/div[1]/h2[contains(.,'BulkEditTestTitleJudo')]
if (not sel.is_element_present(gTitlePathOnViewVideoPage + gEditTitle + "')]") ):
print "ERROR: Title was not found or it is incorrect"
self.failUnless(False)
if (not sel.is_element_present(gUserPathOnViewVideoPage + gBulkEditUserName + "')]") ):
print "ERROR: User's Name was not found or it is incorrect"
self.failUnless(False)
if (not sel.is_element_present(gDescriptionPathOnViewVideoPage + gEditDescription + "')]") ):
print "ERROR: Description was not found or it is incorrect"
self.failUnless(False)
if (not sel.is_element_present(gCategoryPathOnViewVideoPage + gCategoryName + "')]") ):
print "ERROR: Category was not found or it is incorrect"
self.failUnless(False)
if in_CheckTags:
if (not sel.is_element_present(gTagsPathOnViewVideoPage + gEditTag + "')]") ):
print "ERROR: Tag was not found or it is incorrect"
self.failUnless(False)
return 1
def LoginDeleteVideosAddVideos(self):
print "Loging in as admin and going to the 'View Admin' page..."
self.LoginAsAdminSetThemeGoToViewAdmin()
print "Deleting videos..."
self.DeleteVideos()
print "Submitting the first video..."
self.SubmitVideo(gVideo1Url)
print "Submitting the second video..."
self.SubmitVideo(gVideo2Url)
def LoginDeleteVideosAddUserAddCategoryAddVideos(self):
print "Loging in as admin and going to 'View Admin' page..."
self.LoginAsAdminSetThemeGoToViewAdmin()
print "Deleting videos..."
self.DeleteVideos()
print "Adding a user..."
self.AddUser()
print "Adding a category..."
self.AddCategory()
print "Submitting the first video..."
self.SubmitVideo(gVideo1Url)
print "Submitting the second video..."
self.SubmitVideo(gVideo2Url)
#Tests AUT for edititng and deleting videos by 'Bulk Edit'
class testcase_BulkEdit_EditAndDelete(testcase_BaseClassForBulkEdit):
#The body of test case
def test_case(self):
print ""
print "Starting 'testcase_BulkEdit_EditAndDelete' test case..."
sel = self.selenium
self.LoginDeleteVideosAddUserAddCategoryAddVideos()
print "Opening 'Bulk Edit' page..."
sel.click(gBulkEditOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Searching all videos with 'gVideosLabel'..."
sel.type(gSearchEditBoxOnBulkEditPage, gVideosLabel)
sel.click(gSearchButtonOnBulkEditPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Checking all found videos..."
sel.click(gToggleAll)
print "Choosing 'Edit' option and clicking 'Apply' button..."
sel.select(gActionSelector, gEditOption)
sel.click(gApplyButton)
print "Editing selected videos..."
WaitUntilElementOnTheScreen(sel, gEditCategoryXPath, gTimeOut)
sel.type(gEditPageTitleEditField, "")
sel.type(gEditPageTitleEditField, gEditTitle)
sel.type(gEditPageDateEditField, "")
sel.type(gEditPageDateEditField, gEditDate)
sel.type(gEditPageDescriptionEditField, "")
sel.type(gEditPageDescriptionEditField, gEditDescription)
sel.type(gEditPageTagsEditField, "")
sel.type(gEditPageTagsEditField, gEditTag)
sel.check(gEditCategoryXPath)
sel.check(gEditUserXPath)
print "Saving changes..."
sel.click(gSaveChangesButtonInEditWindow)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Checking changes in the first video..."
self.checkChanges(gLinkToViewFirstVideo, True)
sel.click(gViewAdmin)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
sel.click(gBulkEditOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
sel.type(gSearchEditBoxOnBulkEditPage, gVideosLabel)
sel.click(gSearchButtonOnBulkEditPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Checking changes in the second video..."
self.checkChanges(gLinkToViewSecondVideo, True)
# Delete
print "Deleting videos..."
sel.click(gViewAdmin)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
self.DeleteVideos()
print "Verifying if videos have been deleted..."
sel.click(gBulkEditOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
sel.type(gSearchEditBoxOnBulkEditPage, gVideosLabel)
sel.click(gSearchButtonOnBulkEditPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
if (sel.is_element_present(gFirstVideoTitlePathOnBulkEditPage + gEditTitle + "')]") ):
print "ERROR: Video was not deleted"
self.failUnless(False)
if (sel.is_element_present(gSecondVideoTitlePathOnBulkEditPage + gEditTitle + "')]") ):
print "ERROR: Video was not deleted"
self.failUnless(False)
#Tests AUT for featuring and unfeaturing videos by 'Bulk Edit'
class testcase_BulkEdit_FeatureAndUnfeature(testcase_BaseClassForBulkEdit):
#The body of test case
def test_case(self):
print ""
print "Starting 'testcase_BulkEdit_FeatureAndUnfeature' test case..."
sel = self.selenium
self.LoginDeleteVideosAddVideos()
print "Opening 'Bulk Edit' page..."
sel.click(gBulkEditOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Searching all videos with 'gVideosLabel'..."
sel.type(gSearchEditBoxOnBulkEditPage, gVideosLabel)
sel.click(gSearchButtonOnBulkEditPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Featuring all found videos..."
sel.click(gToggleAll)
sel.select(gActionSelector, gFeatureOption)
sel.click(gApplyButton)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Verifying if videos have been featured..."
sel.select(gFilterSelector, gFeaturedFilterOption)
sel.click(gSearchButtonOnBulkEditPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
if (not sel.is_element_present(gVideoPathOnBulkEditPage + gFirstVideoOriginalName + "')]") ):
print "ERROR: Video was not featured"
self.failUnless(False)
if (not sel.is_element_present(gVideoPathOnBulkEditPage + gSecondVideoOriginalName + "')]") ):
print "ERROR: Video was not featured"
self.failUnless(False)
#---
print "Unfeaturing videos..."
sel.click(gToggleAll)
sel.select(gActionSelector, gUnfeatureOption)
sel.click(gApplyButton)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Verifying if videos have been unfeatured..."
sel.select(gFilterSelector, gFeaturedFilterOption)
sel.click(gSearchButtonOnBulkEditPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
if (sel.is_element_present(gVideoPathOnBulkEditPage + gFirstVideoOriginalName + "')]") ):
print "ERROR: Video was not unfeatured"
self.failUnless(False)
if (sel.is_element_present(gVideoPathOnBulkEditPage + gSecondVideoOriginalName + "')]") ):
print "ERROR: Video was not unfeatured"
self.failUnless(False)
#Tests AUT for editing a single video
class testcase_BulkEdit_EditSingleVideo(testcase_BaseClassForBulkEdit):
#The body of test case
def test_case(self):
print ""
print "Starting 'testcase_BulkEdit_EditSingleVideo' test case..."
sel = self.selenium
self.LoginDeleteVideosAddUserAddCategoryAddVideos()
print "Opening 'Bulk Edit' page..."
sel.click(gBulkEditOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Searching all videos with 'gVideosLabel'..."
sel.type(gSearchEditBoxOnBulkEditPage, gVideosLabel)
sel.click(gSearchButtonOnBulkEditPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Editing the first video..."
sel.click(gFirstVideoEditLink)
WaitUntilElementOnTheScreen(sel, gEditCategoryXPathSingleVideo, gTimeOut)
sel.type(gEditPageTitleEditFieldSingleVideo, gEditTitle)
sel.type(gEditPageDateEditFieldSingleVideo, gEditDate)
sel.type(gEditPageDescriptionEditFieldSingleVideo, gEditDescription)
sel.type(gEditPageTagsEditFieldSingleVideo, gEditTag)
sel.check(gEditCategoryXPathSingleVideo)
sel.check(gEditUserXPathSingleVideo)
print "Saving changes..."
sel.click(gSaveChangesButtonInEditWindow)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Checking changes in the first video..."
self.checkChanges(gLinkToViewFirstVideo, False)
time.sleep(10)
#Tests AUT for deleting a single video
class testcase_BulkEdit_DeleteSingleVideo(testcase_BaseClassForBulkEdit):
def test_case(self):
print ""
print "Starting 'testcase_BulkEdit_DeleteSingleVideo' test case..."
sel = self.selenium
self.LoginDeleteVideosAddVideos()
print "Opening 'Bulk Edit' page..."
sel.click(gBulkEditOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Searching all videos with 'gVideosLabel'..."
sel.type(gSearchEditBoxOnBulkEditPage, gVideosLabel)
sel.click(gSearchButtonOnBulkEditPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Deleting the first video..."
sel.click(gFirstVideoDeleteLink)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Checking if video has been deleted..."
if (sel.is_text_present(gFirstVideoOriginalName)):
print "ERROR: Video has not been deleted"
self.failUnless(False)
#Tests AUT for unapproving current videos
class testcase_BulkEdit_UnapproveCurrent(testcase_BaseClassForBulkEdit):
#dummy function
def FeaturingVideos(self):
return 1
def SearchingVideos(self):
sel = self.selenium
print "Searching all videos with 'gVideosLabel'..."
sel.type(gSearchEditBoxOnBulkEditPage, gVideosLabel)
sel.click(gSearchButtonOnBulkEditPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
def test_case(self):
print ""
sel = self.selenium
self.LoginDeleteVideosAddVideos()
#it's dummy function
self.FeaturingVideos()
print "Opening 'Review Queue' page..."
sel.click(gReviewQueueOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Clearing the queue..."
if sel.is_element_present(gClearQueueButtonOnReviewQueuePage):
sel.click(gClearQueueButtonOnReviewQueuePage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
sel.click(gYesClearQueueButton)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Opening 'Bulk Edit' page..."
sel.click(gBulkEditOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
#Searches videos
self.SearchingVideos()
print "Unapproving all found videos..."
sel.click(gToggleAll)
sel.select(gActionSelector, gUnapproveOption)
sel.click(gApplyButton)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Opening 'Review Queue' page..."
sel.click(gReviewQueueOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Checking if video in the 'Review Queue'..."
if (not sel.is_text_present(gFirstVideoOriginalName)):
print "ERROR: Video is not in the list"
self.failUnless(False)
print "Checking if video in the 'Review Queue'..."
if (not sel.is_text_present(gSecondVideoOriginalName)):
print "ERROR: Video is not in the list"
self.failUnless(False)
#Tests AUT for unapproving featured videos
class testcase_BulkEdit_UnapproveFeatured(testcase_BulkEdit_UnapproveCurrent):
#This function searches videos
def SearchingVideos(self):
sel = self.selenium
print "Searching all featured videos with 'gVideosLabel'..."
sel.select(gFilterSelector, gFeaturedFilterOption)
sel.type(gSearchEditBoxOnBulkEditPage, gVideosLabel)
sel.click(gSearchButtonOnBulkEditPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
#This function features videos
def FeaturingVideos(self):
sel = self.selenium
print "Opening 'Bulk Edit' page..."
sel.click(gBulkEditOnAdminPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Searching all videos with 'gVideosLabel'..."
sel.type(gSearchEditBoxOnBulkEditPage, gVideosLabel)
sel.click(gSearchButtonOnBulkEditPage)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
print "Featuring all found videos..."
sel.click(gToggleAll)
sel.select(gActionSelector, gFeatureOption)
sel.click(gApplyButton)
sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
#Tests AUT for sorting videos by 'Video Title' on 'Bulk Edit page'
class testcase_BulkEdit_SortByTitle(testcase_BaseClassForBulkEdit):
cFirstPage = True
cFirstVideoTitleLower = ""
cSecondVideoTitleLower = ""
cFirstVideoTitleOridinal = ""
cSecondVideoTitleOriginal = ""
cPreviousComparison = ""
cPageNumber = 0
cGetElementMethod = None
cCompareMethod = None
cSortingLink = None
cMonths = ["jan, ","feb, ","mar, ","apr, ","may, ","jun, ","jul, ","aug, ","sep, ","oct, ","nov, ","dec, "]
#function that compares two strings
def compareTwoStrings_(self, in_Str1, in_Str2):
if in_Str1 > in_Str2:
return ">"
elif in_Str1 < in_Str2:
return "<"
else:
return "=="
#function that compares two Dates, the blank Date is lower that any other that has value
def compareTwoDates(self, in_Str1, in_Str2):
in_Str1 = in_Str1.lower()
in_Str2 = in_Str2.lower()
if in_Str1 == "":
if in_Str2 != "":
return "<"
else:
return "=="
elif in_Str2 =="":
return ">"
lMonth1 = -1
lMonth2 = -1
lYear1 = -1
lYear2 = -1
lDay1 = -1
lDay2 = -1
for i in range(0, len(self.cMonths)):
if in_Str1.find(self.cMonths[i]) != -1:
in_Str1 = in_Str1.replace(self.cMonths[i], "")
lMonth1 = i
in_Str1.replace(" ", "")
lTempStr = in_Str1.partition(" ")
lDay1 = long(lTempStr[0])
lYear1 = long(lTempStr[2])
for i in range(0, len(self.cMonths)):
if in_Str2.find(self.cMonths[i]) != -1:
in_Str2 = in_Str2.replace(self.cMonths[i], "")
lMonth2 = i
in_Str2.replace(" ", "")
lTempStr = in_Str2.partition(" ")
lDay2 = long(lTempStr[0])
lYear2 = long(lTempStr[2])
lResultStr1 = lYear1*500 + lMonth1*40 + long(lDay1)
lResultStr2 = lYear2*500 + lMonth2*40 + long(lDay2)
if lResultStr1 > lResultStr2:
return ">"
elif lResultStr1 < lResultStr2:
return "<"
else:
return "=="
#returns XPath to a page link with specified number from 'Bulk Edit' page
def getPageLink_(self, in_Number):
return gPageLinkPart1+str(in_Number)+gPageLinkPart2
#returns XPath for a Video's 'Video Title', needed row(video) specified by number
def getVideoTitlePath_(self, in_Number):
return gVideoTitleOnBulkEditPagePart1+str(in_Number)+gVideoTitleOnBulkEditPagePart2
#returns XPath for a Video's 'Source', needed row(video) specified by number
def getSourceTitlePath_(self, in_Number):
return gSourceTitleOnBulkEditPagePart1+str(in_Number)+gSourceTitleOnBulkEditPagePart2
#returns XPath for a Video's 'Date Published', needed row(video) specified by number
def getDatePublishedTitlePath(self, in_Number):
return gDatePublishedTitleOnBulkEditPagePart1+str(in_Number)+gDatePublishedTitleOnBulkEditPagePart2
#returns XPath for a Video's 'Date Imported', needed row(video) specified by number
def getDateImportedTitlePath(self, in_Number):
return gDateImportedTitleOnBulkEditPagePart1+str(in_Number)+gDateImportedTitleOnBulkEditPagePart2
#checks if page is sorted, it does not check if it's sorted in ascending or descending order, it just check if it's sorted in any way
def checkIfPageIsSorted(self, in_GetElementMethod, in_CompareMethod):
sel = self.selenium
self.cPageNumber = self.cPageNumber + 1
print ""
lNoErrorsIndicator = True
print ""
if self.cFirstPage:
if sel.is_element_present(in_GetElementMethod(1)):
self.cFirstVideoTitleOridinal = sel.get_text(in_GetElementMethod(1))
self.cFirstVideoTitleLower = self.cFirstVideoTitleOridinal.lower()
i = 1
while sel.is_element_present(in_GetElementMethod(i+1)):
self.cSecondVideoTitleOriginal = sel.get_text(in_GetElementMethod(i+1))
self.cSecondVideoTitleLower = self.cSecondVideoTitleOriginal.lower()
lCurrentComparison = in_CompareMethod(self.cFirstVideoTitleLower, self.cSecondVideoTitleLower)
if (lCurrentComparison != "=="):
if (self.cPreviousComparison != ""):
if (lCurrentComparison != self.cPreviousComparison):
print ""
print "ERROR: Elements #", i, "and #", i+1, "on page #", self.cPageNumber, " are not sorted properly!"
print "Value of element #", i, " is ", self.cFirstVideoTitleOridinal
print "Value of element #", i+1, " is ", self.cSecondVideoTitleOriginal
print "Previous comparison is ", self.cPreviousComparison
print "Current comparison is ", lCurrentComparison
print "Char's listing in lower case of element #", i
print "-----"
lStr_ = ""
for j in range(0, len(self.cFirstVideoTitleLower)):
lStr_ = lStr_ + str(ord(self.cFirstVideoTitleLower[j])) + " ,"
print lStr_
print "-----"
print "Char's listing in lower case of element #", i+1
print "-----"
lStr_ = ""
for j in range(0, len(self.cSecondVideoTitleLower)):
lStr_ = lStr_ + str(ord(self.cSecondVideoTitleLower[j])) + " ,"
print lStr_
print "-----"
lNoErrorsIndicator = False
#self.assertEqual(False, True)
try: self.failUnless(False)
except AssertionError, e: self.verificationErrors = "For ERRORs check logs above )))"
#except AssertionError, e: None
self.cPreviousComparison = lCurrentComparison
i = i+1
self.cFirstVideoTitleOridinal = self.cSecondVideoTitleOriginal
self.cFirstVideoTitleLower = self.cSecondVideoTitleLower
return lNoErrorsIndicator
else:
if sel.is_element_present(in_GetElementMethod(1)):
self.cSecondVideoTitleOriginal = sel.get_text(in_GetElementMethod(1))
self.cSecondVideoTitleLower = self.cSecondVideoTitleOriginal.lower()
lCurrentComparison = in_CompareMethod(self.cFirstVideoTitleLower, self.cSecondVideoTitleLower)
if lCurrentComparison != "==":
if (self.cPreviousComparison != ""):
if (lCurrentComparison != self.cPreviousComparison):
print ""
print "ERROR: The last element from page #", self.cPageNumber-1, "and the first element from page #", self.cPageNumber, " are not sorted properly!"
print "Value of the last element from page #", self.cPageNumber-1, " is ", self.cFirstVideoTitleOridinal
print "Value of the first element from page #", self.cPageNumber, " is ", self.cSecondVideoTitleOriginal
print "Previous comparison is ", self.cPreviousComparison
print "Current comparison is ", lCurrentComparison
print "Char's listing in lower case of The last element from page #", self.cPageNumber-1
print "-----"
lStr_ = ""
for j in range(0, len(self.cFirstVideoTitleLower)):
lStr_ = lStr_ + str(ord(self.cFirstVideoTitleLower[j])) + " ,"
print lStr_
print "-----"
print "Char's listing in lower case of the first element from page #", self.cPageNumber
print "-----"
lStr_ = ""
for j in range(0, len(self.cSecondVideoTitleLower)):
lStr_ = lStr_ + str(ord(self.cSecondVideoTitleLower[j])) + " ,"
print lStr_
print "-----"