def DeleteVideo(self, sel, title): # sel.set_timeout(testvars.MCTestVariables["TimeOut"]) sel.set_timeout("300000") # Navigate to Bulk Edit page NavigateToBulkEdit(self, sel) print " " print "Searching for the video..." # Trim the title of metacharacters and digits to avoid problems with search filter # trimmedTitle = mclib.remove_digits(mclib.remove_punctuation(title)) trimmedTitle = mclib.split_by_punctuation_char(title) # print title # print trimmedTitle sel.type("q", trimmedTitle) # Item with zero index is the part of the title before the 1st period sel.click("//div[@id='labels']/form[1]/button") sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) if sel.is_text_present(title) == True: # found video? print "Found video \"" + title + "\" in the list - OK" sel.click("css=td[span[text()=" + title + "]] > div.actions > a.delete_icon") else: mclib.AppendErrorMessage(self, sel, "Query did not return the video " + title) print "Query did not return the video " + title print "Also tried searching by: " + trimmedTitle
def CheckVideoStatus(self,sel,title,status): if (status!="Approved" and status!="Featured" and status!="Rejected"): self.fail("Wrong value of Status parameter passed to CheckVideoStatus subroutine") # Navigate to Bulk Edit page sel.click(testvars.MCUI["AdminBulkEdit"]) sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) print " " print "Searching for the "+status+" video..." # Trim the title of metacharacters and digits to avoid problems with search filter # trimmedTitle = mclib.remove_digits(mclib.remove_punctuation(title)) trimmedTitle = mclib.split_by_punctuation_char(title) # print title # print trimmedTitle sel.type("q",trimmedTitle) # Item with zero index is the part of the title before the 1st period if status=="Featured": sel.select("filter", "label=Featured Videos") time.sleep(20) #the above filter is VERY slow! elif status=="Rejected": sel.select("filter", "label=Rejected Videos") time.sleep(20) #the above filter is VERY slow! sel.click("//div[@id='labels']/form[1]/button") sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) if sel.is_text_present(title)==True: # found video? print "Found video \""+title+"\" in the list of "+status+" videos - OK" return True else: # mclib.AppendErrorMessage(self,sel,"Query did not return the video "+title) print "Query did not return the video "+title print "Also tried searching by: "+trimmedTitle return False
def RejectVideoFromApproved(self, sel, title): sel.open(testvars.MCTestVariables["ReviewQueuePage"]) sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) if queue.CheckVideoStatus(self, sel, title, "Approved") == True: print "Duplicate video found - preparing to delete it..." sel.set_timeout(300000) sel.open(testvars.MCTestVariables["BulkEditPage"]) sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) trimmedTitle = mclib.split_by_punctuation_char(title) # print title # print trimmedTitle sel.type("q", trimmedTitle) sel.click("//div[@id='labels']/form[1]/button") sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) if sel.is_text_present(title) == True: # found video? row = 1 titleElement = "//div[@id='labels']/form[2]/table/tbody/tr[" + str( row) + "]/td[2]/span" while sel.is_element_present(titleElement): tempTitle = sel.get_text(titleElement) if tempTitle == title: break row = row + 1 titleElement = "//div[@id='labels']/form[2]/table/tbody/tr[" + str( row) + "]/td[2]/span" if tempTitle == title: deleteElement = "//div[@id='labels']/form[2]/table/tbody/tr[" + str( row) + "]/td[2]/div/a[2]" sel.click(deleteElement) sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) else: mclib.AppendErrorMessage(self, sel, "Query did not return the video " + title) print "Also tried searching by: " + trimmedTitle self.fail("Cannot proceed with the test scenario")
def RejectVideoFromApproved(self,sel,title): sel.open(testvars.MCTestVariables["ReviewQueuePage"]) sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) if queue.CheckVideoStatus(self,sel,title,"Approved")==True: print "Duplicate video found - preparing to delete it..." sel.set_timeout(300000) sel.open(testvars.MCTestVariables["BulkEditPage"]) sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) trimmedTitle = mclib.split_by_punctuation_char(title) # print title # print trimmedTitle sel.type("q",trimmedTitle) sel.click("//div[@id='labels']/form[1]/button") sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) if sel.is_text_present(title)==True: # found video? row = 1 titleElement="//div[@id='labels']/form[2]/table/tbody/tr["+str(row)+"]/td[2]/span" while sel.is_element_present(titleElement): tempTitle = sel.get_text(titleElement) if tempTitle==title: break row = row + 1 titleElement="//div[@id='labels']/form[2]/table/tbody/tr["+str(row)+"]/td[2]/span" if tempTitle==title: deleteElement = "//div[@id='labels']/form[2]/table/tbody/tr["+str(row)+"]/td[2]/div/a[2]" sel.click(deleteElement) sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) else: mclib.AppendErrorMessage(self,sel,"Query did not return the video "+title) print "Also tried searching by: "+trimmedTitle self.fail("Cannot proceed with the test scenario")
def ApproveRejectedVideo(self, sel, title): # sel.set_timeout(testvars.MCTestVariables["TimeOut"]) sel.set_timeout("300000") # Navigate to Bulk Edit page NavigateToBulkEdit(self, sel) print " " print "Searching for the video..." # Trim the title of metacharacters and digits to avoid problems with search filter # trimmedTitle = mclib.remove_digits(mclib.remove_punctuation(title)) trimmedTitle = mclib.split_by_punctuation_char(title) # print title # print trimmedTitle sel.type("q", trimmedTitle) sel.select("name=filter", "label=Rejected Videos") sel.click("css=button.med_button") sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) # Item with zero index is the part of the title before the 1st period sel.check("css=input#id_form-0-BULK") sel.select("id=bulk_action_selector", "label=Approve") sel.click("css=div.bulkedit_controls > button.med_button") sel.click("//div[@id='massedit']/button") sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
def ApproveRejectedVideo(self,sel,title): # sel.set_timeout(testvars.MCTestVariables["TimeOut"]) sel.set_timeout("300000") # Navigate to Bulk Edit page NavigateToBulkEdit(self,sel) print " " print "Searching for the video..." # Trim the title of metacharacters and digits to avoid problems with search filter # trimmedTitle = mclib.remove_digits(mclib.remove_punctuation(title)) trimmedTitle = mclib.split_by_punctuation_char(title) # print title # print trimmedTitle sel.type("q",trimmedTitle) sel.select("name=filter", "label=Rejected Videos") sel.click("css=button.med_button") sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) # Item with zero index is the part of the title before the 1st period sel.check("css=input#id_form-0-BULK") sel.select("id=bulk_action_selector", "label=Approve") sel.click("css=div.bulkedit_controls > button.med_button") sel.click("//div[@id='massedit']/button") sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
def DeleteVideo(self,sel,title): # sel.set_timeout(testvars.MCTestVariables["TimeOut"]) sel.set_timeout("300000") # Navigate to Bulk Edit page NavigateToBulkEdit(self,sel) print " " print "Searching for the video..." # Trim the title of metacharacters and digits to avoid problems with search filter # trimmedTitle = mclib.remove_digits(mclib.remove_punctuation(title)) trimmedTitle = mclib.split_by_punctuation_char(title) # print title # print trimmedTitle sel.type("q",trimmedTitle) # Item with zero index is the part of the title before the 1st period sel.click("//div[@id='labels']/form[1]/button") sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) if sel.is_text_present(title)==True: # found video? print "Found video \""+title+"\" in the list - OK" sel.click("css=td[span[text()="+title+"]] > div.actions > a.delete_icon") else: mclib.AppendErrorMessage(self,sel,"Query did not return the video "+title) print "Query did not return the video "+title print "Also tried searching by: "+trimmedTitle
def CheckVideoStatus(self, sel, title, status): # sel.set_timeout(testvars.MCTestVariables["TimeOut"]) sel.set_timeout("300000") if (status != "Approved" and status != "Featured" and status != "Rejected"): self.fail( "Wrong value of Status parameter passed to CheckVideoStatus subroutine" ) # Navigate to Bulk Edit page sel.open(testvars.MCTestVariables["BulkEditPage"]) # sel.click(testvars.MCUI["AdminBulkEdit"]) sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) print " " print "Searching for the " + status + " video..." # Trim the title of metacharacters and digits to avoid problems with search filter # trimmedTitle = mclib.remove_digits(mclib.remove_punctuation(title)) trimmedTitle = mclib.split_by_punctuation_char(title) # print title # print trimmedTitle sel.type("q", trimmedTitle) # Item with zero index is the part of the title before the 1st period if status == "Featured": sel.select("filter", "label=Featured Videos") time.sleep(20) #the above filter is VERY slow! elif status == "Rejected": sel.select("filter", "label=Rejected Videos") time.sleep(20) #the above filter is VERY slow! sel.click("//div[@id='labels']/form[1]/button") sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"]) if sel.is_text_present(title) == True: # found video? print "Found video \"" + title + "\" in the list of " + status + " videos - OK" return True else: # mclib.AppendErrorMessage(self,sel,"Query did not return the video "+title) print "Query did not return the video " + title print "Also tried searching by: " + trimmedTitle return False