def AddToPlaylist(self, sel, theme, playlist):
    if sel.is_element_present("css=div.playlist_title > a:contains('" +
                              playlist + "')"):
        mclib.AppendErrorMessage(
            self, sel, "This video has alreday been added to playlist " +
            playlist + ". Cannot proceed with the test")
    if sel.is_element_present("css=select#id_playlist > option:contains('" +
                              playlist + "')"):
        print "Playlist " + playlist + " found, adding video..."
        sel.select("id=id_playlist", "label=" + playlist)
        time.sleep(2)
        sel.click("css=input[type=\"submit\"]")
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
    else:
        # Create new playlist
        print "Playlist " + playlist + " not found, creating new playlist..."
        sel.select("id=id_playlist", "label=New Playlist...")
        time.sleep(2)
        sel.answer_on_next_prompt(playlist)
        sel.click("css=input[type=\"submit\"]")
        time.sleep(2)
        self.assertEqual("Enter the name for the new playlist:",
                         sel.get_prompt())
        time.sleep(5)
    print "Checking that the video has been added to playlist"
    #    if sel.is_element_present("css=div.playlist_title > a:contains('"+playlist+"')")==False:
    if sel.is_text_present(playlist) == False:
        #        print sel.get_text("css=div#playlists div ul li")
        mclib.AppendErrorMessage(
            self, sel,
            "The marker of playlist " + playlist + " has not been found")
    else:
        print "OK"
Exemple #2
0
def SubmitDuplicateVideo(self, sel, video_url, theme):
    print "Attempting to submit video: " + str(video_url) + "..."
    if theme == 4:  # Blue theme
        submitVideoButton = "//div[@id='nav']/ul/li[6]/a"
    else:  # Any other front page theme
        submitVideoButton = "//ul[@id='nav']/li[6]/a/span"
    print "Checking if 'Submit Video' button is accessible..."
    if sel.is_element_present(submitVideoButton) == False:
        mclib.AppendErrorMessage(self, sel,
                                 "Could not find 'Submit Video' button")
    else:
        print "OK. Clicking the button..."
        sel.click(submitVideoButton)
        if CheckTextPresent(self, sel, "Enter the URL of your video", 30,
                            "Time out") == False:
            mclib.AppendErrorMessage(
                self, sel, "Could not find the prompt to enter the video URL")
        else:
            print "OK. Entering the video URL..."
            sel.type("id_url", video_url)
            print "Now trying to actually submit the video..."
            sel.click("//input[@value='Submit']")
            time.sleep(5)
            # Retrieving and storing video attributes
            if sel.is_text_present(
                    'That video has already been submitted!') == False:
                mclib.AppendErrorMessage(
                    self, sel,
                    'Expected error message on video duplicaton not found')
            else:
                sel.click("//div[@id='overlay']/div[1]")
                alertText = sel.get_text("//form[@id='submit_video']/div[2]")
                print "Message text: "
                print alertText
                print "OK - the submission attempt was rejected as expected"
Exemple #3
0
def DeleteUser(self, sel, username, allusers):
    if allusers == 0: usRow = UserRow(self, sel, username)
    elif allusers == 1:
        usRow = UserRowInCompleteListOfAuthors(self, sel, username)
    else:
        self.fail(
            "Wrong value of ALLUSERS parameter passed to function DeleteUser")
    if usRow == 0:
        mclib.AppendErrorMessage(
            self, sel,
            "Username " + username + " not found. Cannot delete it.")
    else:
        if allusers == 0: sel.open(testvars.MCTestVariables["UserPage"])
        else: sel.open(testvars.MCTestVariables["UserPage"] + "/?show=all")
        elementDelete = "//div[@id='labels']/form/table/tbody/tr[" + str(
            usRow) + "]/td[2]/div/a[2]"
        if sel.is_element_present(elementDelete) == False:
            mclib.AppendErrorMessage(
                self, sel, "Delete link not found for username " + username)
        else:
            print "Deleting user " + username + "..."
            sel.click(elementDelete)
            sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
            print "Checking that the user was deleted..."
            if (allusers == 0 and UserRow(self, sel, username)) == 0:
                print "OK"
            elif (allusers == 1 and UserRowInCompleteListOfAuthors(
                    self, sel, username)) == 0:
                print "OK"
            else:
                print mclib.AppendErrorMessage(
                    self, sel, "Could not delete username " + username)
Exemple #4
0
def DeleteBackgroundImage(self,sel):
    NavigateToSettingsPage(self,sel)
    print "Deleting background..."
    if sel.is_element_present("delete_background")==False:
        mclib.AppendErrorMessage(self,sel,"Delete Background button not found")
    else:
        sel.click("delete_background")
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        sel.open(testvars.MCTestVariables["CategoriesPage"])
        time.sleep(2)
        sel.open(testvars.MCTestVariables["SettingsPage"])
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        sel.click("submit_settings")
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        # Go to Main Site
        sel.open(testvars.MCTestVariables["CategoriesPage"])
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        print "Checking that Home page does not have a background image"
        #sel.click(testvars.MCTestVariables["ViewMainSiteLink"])
        sel.open(testvars.MCTestVariables["TestSite"])
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        # Looking for a background image in HTML source
        stringSource = sel.get_html_source()
        queryText = "background: url(\""+testvars.MCTestVariables["SiteBackgroundURL"]
        if stringSource.find(queryText)==-1:
            print "Background image was successfully deleted"
        else:
            mclib.AppendErrorMessage(self,sel,"Background image was not deleted")
def PostEditorsComment(self, sel, editorscomment):
    linkEditorsComment = "css=div.main > div.editable > div.display_data > a.edit_link"
    dialogEditorsComment = "css=div.main > div.editable > div.simple_overlay > h2:contains('Editing Editors comment')"
    sel.click(linkEditorsComment)
    time.sleep(5)
    if sel.is_visible(dialogEditorsComment) != True:
        mclib.AppendErrorMessage(
            self, sel, "Dialog for posting the editors comment was not found")
    else:
        sel.type("id=id_editors_comment", editorscomment)
        sel.click("css=button.done")
        time.sleep(3)
        print "Done"
        print "Checking that the website URL has been updated correctly..."
        #        linkEditorsComment = "css=div.description:nth-child(1)"
        linkEditorsComment = "css=div.editors_notes"
        str = sel.get_text(linkEditorsComment)
        postedComment = re.split("writes: ", str.replace("\n", ""))
        #        print postedComment
        if postedComment[1] != mclib.remove_html_tags(editorscomment):
            mclib.AppendErrorMessage(
                self, sel,
                "The Editor's Comment has not been updated as expected")
            print "Expected value: " + mclib.remove_html_tags(editorscomment)
            print "- Actual value: " + postedComment[1]
        else:
            print "OK - test passed"
def InlineEditDescription(self, sel, theme, newdescription):
    if theme == 4:
        linkEditDescription = "css=div.editable > div.display_data > h4.meta_title > a.edit_link"
        dialogEditDescription = "css=div.simple_overlay:contains('Editing Description')"
    else:
        linkEditDescription = "css=div.editable > div.display_data > h4.meta_title > a.edit_link"
        dialogEditDescription = "css=div#main > div.editable > div.simple_overlay > h2"
    print "Editing the description..."
    sel.click(linkEditDescription)
    time.sleep(5)
    if sel.is_visible(dialogEditDescription) != True:
        mclib.AppendErrorMessage(
            self, sel,
            "Dialog for inline editing of the description was not found")
    else:
        sel.type("id=id_description", newdescription)
        sel.click("css=button.done")
        time.sleep(3)
        print "Done"
        print "Checking that the description has been updated correctly..."
        linkDescription = "css=div.editable > div.display_data > div.description"
        updatedDescription = sel.get_text(linkDescription)
        if updatedDescription != mclib.remove_html_tags(newdescription):
            mclib.AppendErrorMessage(
                self, sel, "The description has not been updated as expected")
            print "Expected value: " + mclib.remove_html_tags(newdescription)
            print "- Actual value: " + updatedDescription
        else:
            print "OK - test passed"
def InlineEditWebsite(self, sel, theme, newwebsite):
    if theme == 4:
        print "Website URL for a video cannot be edited in Blue Theme. Test skipped."
        return
    else:
        linkEditWebsite = "css=div#main > div#tags > ul.meta_listing > li.item > div.editable > div.display_data > div.floatleft > h3 > a.edit_link"
        dialogEditWebsite = "css=div#main > div#tags > ul.meta_listing > li.item:nth-child(3) > div.editable > div.simple_overlay > h2"
        print "Editing the website URL..."
        sel.click(linkEditWebsite)
        time.sleep(5)
        if sel.is_visible(dialogEditWebsite) != True:
            mclib.AppendErrorMessage(
                self, sel,
                "Dialog for inline editing of the website URL was not found")
        else:
            sel.type("id=id_website_url", newwebsite)
            sel.click("css=button.done")
            time.sleep(3)
            print "Done"
            print "Checking that the website URL has been updated correctly..."
            linkWebsite = "css=span.url"
            updatedWebsite = sel.get_text(linkWebsite)
            if updatedWebsite != newwebsite:
                mclib.AppendErrorMessage(
                    self, sel,
                    "The website URL has not been updated as expected")
                print "Expected value: " + newwebsite
                print "- Actual value: " + updatedWebsite
            else:
                print "OK - test passed"
def InlineEditPublicationDate(self, sel, theme, newdate):
    if theme == 4:
        linkEditDate = "css=div.posted_at > div.editable > div.display_data > span.edit_link"
        dialogEditDate = "css=div.posted_at > div.editable > div.simple_overlay > h2"
    else:
        linkEditDate = "css=div.date > div.editable > div.display_data > span.edit_link"
        dialogEditDate = "css=div.date > div.editable > div.simple_overlay > h2"
    sel.click(linkEditDate)
    time.sleep(5)
    if sel.is_visible(dialogEditDate) != True:
        mclib.AppendErrorMessage(
            self, sel,
            "Dialog for inline editing the publication date was not found")
    else:
        sel.type("css=input#id_when_published", newdate)
        sel.click("css=button.done")
        time.sleep(3)
        print "Verifying that the publication date has been changed..."
        sel.click(dialogEditDate)
        if sel.get_value("css=input#id_when_published") == newdate:
            print "OK"
        else:
            mclib.AppendErrorMessage(
                self, sel,
                "The publication date has not been updated correctly")
        sel.click("css=a.close")
def InlineEditAuthor(self, sel, theme, newauthor):
    if theme == 4:
        linkCurrentAuthor = "css=div.vid_author > div.posted_by > div.editable > div.display_data > a"
        dialogEditAuthor = "css=div.vid_author > div.posted_by > div.editable > div.simple_overlay > h2"
    else:
        linkCurrentAuthor = "css=div.byline > div.editable > div.display_data > a"
        dialogEditAuthor = "css=div.byline > div.editable > div.simple_overlay > h2"
    linkEditAuthor = linkCurrentAuthor + ".edit_link"
    currentAuthor = sel.get_text(linkCurrentAuthor)
    print "The current author for this video is '" + currentAuthor + "'"
    print "Updating the author..."
    sel.click(linkEditAuthor)
    time.sleep(5)
    if sel.is_visible(dialogEditAuthor) != True:
        mclib.AppendErrorMessage(
            self, sel, "Dialog for inline editing the author was not found")
    else:
        sel.uncheck("//li/label[span='" + currentAuthor +
                    "']/input[@name='authors']")
        sel.check("//li/label[span='" + newauthor +
                  "']/input[@name='authors']")
        sel.click("css=button.done")
        time.sleep(3)
        print "Done"
        print "Checking that the author has been updated correctly..."
        updatedAuthor = sel.get_text(linkCurrentAuthor)
        if updatedAuthor != newauthor:
            mclib.AppendErrorMessage(
                self, sel, "The author has not been updated as expected")
            print "Expected value: " + newauthor
            print "- Actual value: " + updatedAuthor
        else:
            print "OK - test passed"
Exemple #10
0
def AddCustomCSS(self,sel,customcss):
    NavigateToSettingsPage(self,sel)
    print "Adding custom CSS..."
    if sel.is_element_present("id_css")==False:
        mclib.AppendErrorMessage(self,sel,"Custom CSS edit field not found")
    else:
        sel.type("id_css",customcss)
        sel.click("submit_settings")
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        sel.open(testvars.MCTestVariables["SettingsPage"])
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        # Looking for custom CSS in HTML source - admin
        #sel.click(testvars.MCUI["AdminVideos"])
        sel.open(testvars.MCTestVariables["ReviewQueuePage"])
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        print "Checking that admin page does not have custom CSS"
        stringSource = sel.get_html_source()
        if stringSource.find(customcss)==-1:
            print "Custom CSS did not add to admin pages - PASS"
        else:
            mclib.AppendErrorMessage(self,sel,"Custom CSS was added to admin pages")
        # Go to Main Site
        #sel.click(testvars.MCTestVariables["ViewMainSiteLink"])
        sel.open(testvars.MCTestVariables["TestSite"])
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        # Looking for custom CSS in HTML source - front pages
        print "Checking that Home page has custom CSS"
        stringSource = sel.get_html_source()
        if stringSource.find(customcss)!=-1:
            print "Custom CSS was successfully added to front pages"
        else:
            mclib.AppendErrorMessage(self,sel,"Custom CSS was not added to front pages")
def ChangeThumbnail(self, sel, theme, thumbURL, thumbFile):
    linkCaption = "Upload/Replace Thumbnail"
    print "Looking for " + linkCaption + " ..."
    linkUploadThumbnail = "link=" + linkCaption
    if sel.is_element_present(linkUploadThumbnail) == False:
        mclib.AppendErrorMessage(self, sel,
                                 "Upload/Replace Thumbnail link not found")
    else:
        print "Clicking " + linkCaption + " ..."
        sel.click(linkUploadThumbnail)
        time.sleep(5)
        overlayEditingThumbnail = "css=div.editable div.simple_overlay h2"
        if sel.is_visible(overlayEditingThumbnail) == False:
            mclib.AppendErrorMessage(
                self, sel, "Dialog for Editing Thumbnail was not found")
        else:
            print "OK"
            print "Entering the new thumbnail..."
            if thumbURL != "": sel.type("css=input#id_thumbnail_url", thumbURL)
            elif thumbFile != "": sel.type("css=input#id_thumbnail", thumbFile)
            else:
                mclib.AppendErrorMessage(self, sel,
                                         "New thumbnail was not provided")
            sel.click("css=button.done")
            time.sleep(5)
            print "Done"
Exemple #12
0
def DeleteCustomCSS(self,sel):
    NavigateToSettingsPage(self,sel)
    print "Deleting custom CSS..."
    if sel.is_element_present("id_css")==False:
        mclib.AppendErrorMessage(self,sel,"Custom CSS edit field not found")
    else:
        sel.type("id_css","")
        sel.click("submit_settings")
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        sel.open(testvars.MCTestVariables["SettingsPage"])
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        # Looking for custom CSS in HTML source - admin
#        sel.click(testvars.MCUI["AdminVideos"])
        sel.open(testvars.MCTestVariables["ReviewQueuePage"])
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        # Go to Main Site
        #sel.click(testvars.MCTestVariables["ViewMainSiteLink"])
        sel.open(testvars.MCTestVariables["TestSite"])
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        # Looking for custom CSS in HTML source - front pages
        print "Checking that Home page does not have custom CSS"
        styleTag = "<style type=\"text/css\">"
        stringSource = sel.get_html_source()
        if stringSource.find(styleTag)==-1:
            print "Custom CSS was successfully removed from front pages"
        else:
            mclib.AppendErrorMessage(self,sel,"Custom CSS was not removed from front pages")
Exemple #13
0
def HideSubmitVideo(self,sel,theme):
    NavigateToSettingsPage(self,sel)
    print "Unchecking Display 'Submit a Video' check box..."
    if sel.is_element_present("id_display_submit_button")==False:
        mclib.AppendErrorMessage(self,sel,"Display 'Submit a Video' button check box not found")
    else:
        sel.uncheck("id_display_submit_button")
        sel.click("submit_settings")
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        sel.open(testvars.MCTestVariables["SettingsPage"])
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        # Go to Main Site
        #sel.click(testvars.MCTestVariables["ViewMainSiteLink"])
        sel.open(testvars.MCTestVariables["TestSite"])
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        # Looking for Submit a Video button on the front pages
        if theme==4:
            submitButton="link=Submit"           #"//div[@id='nav']/ul/li[6]/a"
            submitCaption="Submit"
        else:
            submitButton="//ul[@id='nav']/li[6]/a/span"
            submitCaption="Submit A Video"
        if sel.is_element_present(submitButton)==True and sel.get_text(submitButton)==submitCaption:
            mclib.AppendErrorMessage(self,sel,"Submit a Video button was unexpectedly found on the front pages")
        else:
            print "Submit a Video button not found on front pages - PASS"
Exemple #14
0
def UploadBackgroundImage(self,sel,theme,background):
    NavigateToSettingsPage(self,sel)
    bkgrfile = os.path.join(testvars.MCTestVariables["GraphicFilesDirectory"],background)
    print "Uploading a new background image... "+bkgrfile
    if sel.is_element_present("id_background")==True:
        sel.type("id_background", bkgrfile)
        sel.click("submit_settings")
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        sel.open(testvars.MCTestVariables["SettingsPage"])
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
    else:
        mclib.AppendErrorMessage(self,sel,"Input field for uploading new background image not found")
    # Go to Main Site
    print "Checking background image on Home page"
    #sel.click(testvars.MCTestVariables["ViewMainSiteLink"])
    sel.open(testvars.MCTestVariables["TestSite"])
    sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
    # Looking for a background image in HTML source
    stringSource = sel.get_html_source()
    # We truncate the last 4 chars from the file name because an umpteenth copy of the same
    # file uploaded to the server contains trailing underscores after file name
    # Example: logo.jpg -> logo______.jpg
    siteURL = testvars.MCTestVariables["TestSite"]
    sitename1 = siteURL.replace("http://","")
    print sitename1
    sitename = sitename1.replace(".mirocommunity.org/","")
    print sitename
    SiteBackgroundURL = "http://s3.mirocommunity.org.s3.amazonaws.com/"+sitename+"/localtv/site_backgrounds"

    bbb = background[:(len(background)-4)]
    queryText = "background: url(\""+SiteBackgroundURL+"/"+bbb
    if stringSource.find(queryText)==-1:
        mclib.AppendErrorMessage(self,sel,"Desired background not uploaded correctly")
Exemple #15
0
def ViewUser(self, sel, username, name, location, website, description, image):
    # Detect current theme
    #    sel.click(testvars.MCTestVariables["ViewMainSiteLink"])
    sel.open(testvars.MCTestVariables["TestSite"])
    sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
    # Return back to /admin/users page and attempt to view the user's page
    sel.open(testvars.MCTestVariables["UserPage"])
    sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
    usRow = UserRow(self, sel, username)
    if usRow != 0:
        #sel.open(testvars.MCTestVariables["UserPage"])
        elementView = "//div[@id='labels']/form/table/tbody/tr[" + str(
            usRow) + "]/td[2]/div/a[3]"
        if sel.is_element_present(elementView) == False:
            mclib.AppendErrorMessage(
                self, sel, "View link not found for user " + username)
        else:
            print "Opening page for user " + username + " for viewing"
            sel.click(elementView)
            sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
            # Check that username and proper name are correct
            ViewUserCheck(self, sel, username, name, location, website,
                          description, image)
    else:
        mclib.AppendErrorMessage(self, sel, "Could not find user " + username)
Exemple #16
0
def ApproveVideoPage(self, sel, page):
    NavigateToReviewQueue(self, sel)
    if page == "Last": pageNo = "1000000"
    else: pageNo = page
    # Construct the URL of the page in the queue with the given number
    pageLink = testvars.MCTestVariables["ReviewQueuePage"] + "/?page=" + pageNo
    try:
        sel.open(pageLink)
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
    except:
        pass
    time.sleep(5)
    # Check if there are any videos in the queue for the test to run
    if sel.is_element_present(
            "//div[@id='admin_videolisting_row']/div[1]") == False:
        self.fail(
            "No videos found on the queue page. Not enough test data to run the test."
        )
    # Memorize the list of video titles on the page
    print "Memorizing the list of videos found on the page..."
    videoList = ['']
    for i in range(1, 11):
        titleLink = "//div[@id='admin_videolisting_row']/div[" + str(
            i) + "]/div[1]/h3/a"
        if sel.is_element_present(titleLink) == True:
            newTitle = sel.get_text(titleLink)
            videoList.append(newTitle)
        else:
            videoList.append("None")
    videoList.remove('')
    print "Found the following videos on the queue page " + page + ":"
    print videoList
    # Approve page
    approveButton = "//div[@id='content']/a[1]/span"
    if sel.is_element_present(
            approveButton) == False:  # If approve button not found
        mclib.AppendErrorMessage(
            self, sel,
            "'Approve All the Videos on This Page' button not found")
    else:
        sel.click(approveButton)
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        print "Approved page"
        # Check that all the videos were approved
        print "Checking that all the videos were successfully approved..."
        sel.open("/listing/new/")
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        for item in videoList:
            if item != "None":
                itemLink = "//a[text()='" + item + "']"
                if sel.is_element_present("link=" + item) == True:
                    videoLink = sel.get_attribute("link=" + item + "@href")
                    print "Found video *" + item + "* at URL: " + videoLink
                else:
                    mclib.AppendErrorMessage(
                        self, sel, "Could not find video " + item +
                        " in the list of new videos.")
            else:
                print "N/A"
Exemple #17
0
def EditSiteTagline(self,sel,theme,newtagline):
    NavigateToSettingsPage(self,sel)
# Type the values into edit fields
    if sel.is_element_present("id_tagline")==False:
        mclib.AppendErrorMessage(self,sel,"Site Tagline edit field not found")
    else:
        sel.click("id_tagline")
        sel.type("id_tagline", newtagline)
        if sel.is_element_present("submit_settings")==False:
            mclib.AppendErrorMessage(self,sel,"Save Changes button not found")
        else:
            # Click Save
            sel.click("submit_settings")
            sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
    # ------ Workaround for blank page bug
            sel.open(testvars.MCTestVariables["CategoriesPage"])
            time.sleep(3)
            sel.open(testvars.MCTestVariables["SettingsPage"])
            sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
    # --------- End of workaround insert
            print "Changed site tagline to: "+newtagline
#----- As of Dec.2010, tagline is no longer displayed in the admin interface
           # Check that the TAGLINE in the admin interface is present, visible and correct
#            elementTagline="//div[@id='logo']/h1/span"
#            print "Checking site tagline in the administrator interface..."
#            if sel.is_element_present(elementTagline)==False:
#                mclib.AppendErrorMessage(self,sel,"Tagline is not present in the Administrator interface")
#            elif sel.is_visible(elementTagline)==False:
#                mclib.AppendErrorMessage(self,sel,"Tagline is not visible in the Administrator interface")
#            elif sel.get_text(elementTagline)!=newtagline:
#                mclib.AppendErrorMessage(self,sel,"Wrong site tagline in the administrator interface.")
#                print "Expected tagline is "+newtagline
#                print "- Actual tagline is "+sel.get_text(elementTagline)
#            else:
#                print "OK"
        
# Click View Main Site
            #sel.click(testvars.MCTestVariables["ViewMainSiteLink"])
            sel.open(testvars.MCTestVariables["TestSite"])
            sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
# Check that the TAGLINE on the main site is present, visible and correct
            if theme==4:
                elementTagline="//div[@id='wrapper']/div[1]/div/div[1]/p"
            else:
                elementTagline="//div[@id='logo']/h1/span"
            print "Checking site tagline on the main site..."
            if sel.is_element_present(elementTagline)==False:
                mclib.AppendErrorMessage(self,sel,"Tagline is not present on the main site")
            elif sel.is_visible(elementTagline)==False:
                mclib.AppendErrorMessage(self,sel,"Tagline is not visible on the main site")
            elif sel.get_text(elementTagline)!=newtagline:
                mclib.AppendErrorMessage(self,sel,"Wrong site tagline on the main site.")
                print "Expected tagline is "+newtagline
                print "- Actual tagline is "+sel.get_text(elementTagline)
            else:
                print "OK"
def PostToFacebook(self, sel, theme, videotitle):
    currentpageURL = sel.get_location()
    linkPostFacebook = "css=span.FBConnectButton_Text_Simple"
    sel.click(linkPostFacebook)
    sel.wait_for_pop_up("sharer", testvars.MCTestVariables["TimeOut"])
    sel.select_window("title=Facebook")
    sel.click("css=textarea.uiTextareaNoResize")
    sel.type("css=textarea.uiTextareaNoResize",
             "TEST POST, theme " + str(theme))
    title = sel.get_text("css=a.UIShareStage_InlineEdit")
    if title != videotitle:
        mclib.AppendErrorMessage(
            self, sel,
            "Video title passed to Facebook does not match the real one")
        print "Expected to find: " + videotitle
        print "-Actually passed: " + title
    videoURL = sel.get_text("css=div.UIShareStage_Subtitle")
    #    if videoURL!=currentpageURL:
    #        mclib.AppendErrorMessage(self,sel,"Video URL passed to Facebook does not match the real URL")
    #        print "Expected to find: "+currentpageURL
    #        print "-Actually passed: "+videoURL
    sel.click("css=label.uiButtonConfirm")
    time.sleep(15)
    # Check that the Facebook popup is closed
    if (u'Facebook') in sel.get_all_window_titles():
        mclib.AppendErrorMessage(
            self, sel, "Facebook sharing popup did not close as expected")
    else:
        sel.select_window("null")
        sel.open("http://www.facebook.com")
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        sel.click("link=Pat Culture")
        time.sleep(5)
        if sel.is_text_present(title) == False:
            mclib.AppendErrorMessage(
                self, sel, "New post with the video title not found")
        else:
            if sel.is_element_present("link=" + title) == False:
                mclib.AppendErrorMessage(self, sel,
                                         "Link to the posted video not found")
            else:
                postedURL = sel.get_attribute('//a[text()="' + title +
                                              '"]@href')
                print postedURL
                #                sel.click("link="+title)
                #                sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
                if postedURL != currentpageURL:
                    mclib.AppendErrorMessage(
                        self, sel, "Facebook post links to the wrong page")
                    print "Expected to find: " + currentpageURL
                    print "- Actually found: " + postedURL
                else:
                    print "OK. Test passed"
def VerifyPlaylistsPageIsEnabled(self, sel):
    sel.open(testvars.MCTestVariables["PlaylistsPage"])
    sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
    if sel.is_text_present("Page not found"):
        mclib.AppendErrorMessage(
            self, sel,
            "Playlists page has not been enabled properly - 404 Error")
    elif sel.is_text_present("Goodies | Playlists") == False:
        mclib.AppendErrorMessage(self, sel, "Unexpected page found")
        print sel.get_html_source()
    else:
        print "OK - page enabled, test passed"
 def test_SignUpAndLogin(self):
     sel = self.selenium
     #       Log in as Admin
     loginlogout.LogInAsAdmin(self, sel)
     print "Starting tests..."
     for theme in range(1, 2):
         print ""
         print "============================================"
         print ""
         print "Running Sign Up and Login test with theme: " + str(theme)
         print "Changing theme..."
         sitesettings.ChangeTheme(self, sel, theme)
         loginlogout.LogOut(self, sel)
         newUsername = "******" + time.strftime(
             "%d_%m_%Y__%H_%M", time.localtime()) + "_theme" + str(theme)
         newPassword = "******"
         print "Signing up as user " + newUsername
         loginlogout.SignUp(self, sel, newUsername, newPassword,
                            testvars.MCTestVariables["TestEmail"])
         loginlogout.ActivateUserAccount(
             self, sel, testvars.MCTestVariables["TestEmail"],
             testvars.MCTestVariables["TestEmailPassword"])
         loginlogout.LogInBasic(self, sel, newUsername, newPassword)
         # Navigating to user profile to check the user's account parameters
         print "Checking the user's profile..."
         linkYourProfile = "link=Your Profile"
         if sel.is_element_present(linkYourProfile) == False:
             mclib.AppendErrorMessage(
                 self, sel, "'Your profile' link on Home page not found")
         else:
             sel.click("link=Your Profile")
             sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
             if sel.get_value(
                     "id_email") != testvars.MCTestVariables["TestEmail"]:
                 mclib.AppendErrorMessage(
                     self, sel,
                     "Unexpected user email encountered in User Profile")
                 print "Expected email: " + testvars.MCTestVariables[
                     "TestEmail"]
                 print "- Actual email: " + sel.get_value("id_email")
                 print "Checking user's name on Profile page..."
             if sel.is_element_present("id_username") == False:
                 mclib.AppendErrorMessage(
                     self, sel, "User Name field on Profile page not found")
             else:
                 if sel.get_value("id_username") != newUsername:
                     mclib.AppendErrorMessage(self, sel,
                                              "Unexpected user name found")
                     print "Expected user name: " + newUsername
                     print "- Actual user name: " + sel.get_value(
                         "id_username")
                 else:
                     print "OK"
Exemple #21
0
def LogInAsOpenIDUser(self, sel, username, password):
    sel.open(testvars.MCTestVariables["LoginPage"])
    sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
    sel.window_maximize()
    time.sleep(1)
    tabOpenID = "link=OpenID"
    print "Checking that OpenID tab on Login page exists..."
    if sel.is_element_present(tabOpenID) == False:
        self.fail("OpenID tab not found")
    else:
        print "OK"
        sel.click(tabOpenID)
        time.sleep(7)
        inputOpenID = "css=input.openid"
        if sel.is_element_present(inputOpenID) == False:
            mclib.AppendErrorMessage(
                self, sel, "Could not find the input field for OpenID")
        else:
            sel.type(inputOpenID, username + '.myopenid.com')
            sel.click(
                "css=div#login_tab_openid.inactive div.left form p input.button"
            )
            sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
            if sel.is_element_present("css=input#password") == False:
                mclib.AppendErrorMessage(
                    self, sel, "Edit box for OpenID password not found")
            else:
                sel.type("css=input#password", password)
                sel.click("css=input#signin_button")
                sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
                if sel.is_element_present("css=button#continue-button"):
                    sel.click("css=button#continue-button")
                    time.sleep(5)
                # Navigating to user profile to check the user's account parameters
                print "Checking the user's profile"
                linkYourProfile = "link=Your Profile"
                if sel.is_element_present(linkYourProfile) == False:
                    mclib.AppendErrorMessage(
                        self, sel,
                        "'Your profile' link on Home page not found")
                else:
                    sel.click("link=Your Profile")
                    sel.wait_for_page_to_load(
                        testvars.MCTestVariables["TimeOut"])
                    print "Checking OpenID user's name on Profile page..."
                    if sel.is_element_present("id_username") == False:
                        mclib.AppendErrorMessage(
                            self, sel,
                            "User Name field on Profile page not found")
                    else:
                        print "OpenID user has signed in and is known in the system as " + sel.get_value(
                            "id_username")
Exemple #22
0
def LogInAsGoogleUser(self, sel, email, password):
    sel.open(testvars.MCTestVariables["LoginPage"])
    sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
    sel.window_maximize()
    time.sleep(1)
    tabGoogle = "link=Google"
    print "Checking that Google tab on Login page exists..."
    if sel.is_element_present(tabGoogle) == False:
        self.fail("Google tab not found")
    else:
        print "OK"
        sel.click(tabGoogle)
        time.sleep(7)
        buttonSignIn = "css=div#login_tab_google.inactive div.left form p input.button"
        if sel.is_text_present("Sign in with your Google Account"
                               ) == False or sel.is_element_present(
                                   buttonSignIn) == False:
            mclib.AppendErrorMessage(self, sel,
                                     "Could not find Sign In button")
        else:
            sel.click(buttonSignIn)
            sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
            if sel.is_element_present("css=input#Email") == False:
                mclib.AppendErrorMessage(
                    self, sel, "Edit box for Google email not found")
            else:
                sel.type("css=input#Email", email)
                sel.type("css=input#Passwd", password)
                sel.click("css=input#signIn.g-button")
                sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
                if sel.is_element_present("css=input#approve_button.lsobtn"):
                    sel.click("css=input#approve_button.lsobtn")
                    time.sleep(5)
                # Navigating to user profile to check the user's account parameters
                linkYourProfile = "link=Your Profile"
                mclib.wait_for_element_present(self, sel, linkYourProfile)
                sel.click("link=Your Profile")
                sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
                if sel.get_value("id_email") != email:
                    mclib.AppendErrorMessage(
                        self, sel,
                        "Unexpected user email encountered in User Profile")
                    print "Expected email: " + email
                    print "- Actual email: " + sel.get_value("id_email")
                print "Checking Google user's name on Profile page..."
                if sel.is_element_present("id_username") == False:
                    mclib.AppendErrorMessage(
                        self, sel, "User Name field on Profile page not found")
                else:
                    print "Google user has signed in and is known in the system as " + sel.get_value(
                        "id_username")
Exemple #23
0
def ProcessVideo(self, sel, page, number, action):
    # Check that the value of <action> is correct
    if (action != "Approved" and action != "Featured"
            and action != "Rejected"):
        self.fail(
            "Wrong value of Action parameter passed to ProcessVideo subroutine"
        )
    NavigateToReviewQueue(self, sel)
    if page == "Last": pageNo = "1000000"
    else: pageNo = page
    # Construct the URL of the page in the queue with the given number
    pageLink = testvars.MCTestVariables["ReviewQueuePage"] + "/?page=" + pageNo
    #    print pageLink
    try:
        sel.open(pageLink)
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
    except:
        pass
    #self.fail("Could not open page "+pageNo+" in the queue")
    # Construct the link for approving a video with its number on the page
    if number > 10: number = 10
    elif number < 1: number = 1
    baseLink = "//div[@id='admin_videolisting_row']/div[" + str(number)
    titleLink = baseLink + "]/div[1]/h3/a"
    featureLink = baseLink + "]/div[2]/a[1]/span"
    approveLink = baseLink + "]/div[2]/a[2]/span"
    rejectLink = baseLink + "]/div[2]/a[3]/span"
    # Memorize the title of the chosen video
    if sel.is_element_present(titleLink) == True:
        videoTitle = sel.get_text(titleLink)
    else:
        videoTitle = testvars.preE + " Unknown"
        mclib.AppendErrorMessage(self, sel, "Video title not found")
    # Now determining what to do with the video
    if action == "Featured": actionLink = featureLink
    elif action == "Approved": actionLink = approveLink
    elif action == "Rejected": actionLink = rejectLink
    actionDesc = action[:(len(action) -
                          2)] + "ing"  # Convert <action> to 'gerundiciple'
    print actionDesc + " video No." + str(
        number) + " on queue page " + pageNo + "..."
    if sel.is_element_present(actionLink) == True:
        sel.click(actionLink)
        time.sleep(5)
        print "OK"
    else:
        actionDesc = action[:(len(action) - 1)]
        mclib.AppendErrorMessage(self, sel,
                                 actionDesc + " link not found for the video")
    print CheckVideoStatus(self, sel, videoTitle, action)
Exemple #24
0
def EnablePlaylists(self,sel,option):
    if option!='Yes' and option!='No' and option!='Admins Only':
        mclib.AppendErrorMessage(self,sel,"Wrong parameter passed to EnablePlaylists subroutine")
    else:
        NavigateToSettingsPage(self,sel)
        print "Selecting '"+option+"' from 'Enable Playlists?' drop-down list..."
        if sel.is_element_present("id_playlists_enabled")==False:
            mclib.AppendErrorMessage(self,sel,"'Enable Playlists?' drop-down list not found")
        else:
            sel.select("css=select#id_playlists_enabled","label="+option)
            sel.click("submit_settings")
            print "Done"
            sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
            sel.open(testvars.MCTestVariables["SettingsPage"])
            sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
Exemple #25
0
    def EmailToFriends(self, sel, theme):
        # Selecting video No. <theme> from New Videos listing
        videoTitleLink = videopage.PickVideoFromNewVideosListingPage(
            self, sel, theme)
        videoTitle = sel.get_text(videoTitleLink)
        print "Opening video page for video " + videoTitle + "..."
        sel.click(videoTitleLink)
        sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
        videoPageURL = sel.get_location()
        print "Mailing the link to video to friends..."
        videopage.EmailToFriends(self, sel, theme,
                                 testvars.MCTestVariables["TestEmail"])
        time.sleep(10)
        print "Checking the last email in the inbox..."
        mailUser = testvars.MCTestVariables["TestEmail"]
        mailPassword = testvars.MCTestVariables["TestEmailPassword"]
        mail = imaplib.IMAP4_SSL('imap.gmail.com', 993)
        mail.login(mailUser, mailPassword)
        mail.select('Inbox')
        result, data = mail.search(None, "ALL")
        ids = data[0]  # data is a list.
        id_list = ids.split()  # ids is a space separated string
        latest_email_id = id_list[-1]  # get the latest
        result, data = mail.fetch(
            latest_email_id,
            "(RFC822)")  # fetch the email body (RFC822) for the given ID
        emailHeader = HeaderParser().parsestr(data[0][1])
        print "Email sender: " + emailHeader['From']
        print "Email subject: " + emailHeader['Subject']
        if emailHeader['From'] != "Miro Community <*****@*****.**>":
            mclib.AppendErrorMessage(self, sel, "Unexpected mail sender found")
        elif not (videoTitle in data[0][1]):
            mclib.AppendErrorMessage(self, sel,
                                     "Video title not found in email")
            print "Video title: " + videoTitle
            print data[0][1]
#        elif not('href=3D"'+videoPageURL+'"' in data[0][1]):
#        elif not(videoPageURL in data[0][1]):
#            mclib.AppendErrorMessage(self,sel,"Link to video not found")
#            print "Link to video: "+videoPageURL
#            print data[0][1]
        else:
            print "OK"


#        print 'Message %s\n%s\n' % (latest_email_id, data[0][1])
        mail.close()
        mail.logout()
    def test_ClearQueue_511(self):
        sel = self.selenium
        loginlogout.LogInAsAdmin(self,sel)
        # Memorizing 
        videosRejected = queue.ClearQueue(self,sel)
        # Check that videos were rejected
        print "Checking that videos were successfully rejected..."
        # At present, it is technically impossible to check the status for
        # every video on the rejected page because of an issue with
        # Bulk Edit page (5 or 6 are the viable limit)
        # As a temporary solution until the issue is resolved,
        # just three videos will be checked - the first, the last, and one
        # from the middle
        print "Looking up the following videos:"
        last = len(videosRejected)-1
        videosToCheck = [videosRejected[0],videosRejected[last/2],videosRejected[last]]
        print videosToCheck
        # Searching each selected video in the list of Rejected videos 
        # on Bulk Edit page
        for item in videosToCheck:
            if item!="None":
                newResult=queue.CheckVideoStatus(self,sel,item,"Rejected")
                print item+"__________"+str(newResult)
                if newResult==False:
                    mclib.AppendErrorMessage(self,sel,"Could not find video "+item+" in the list of rejected videos.")
                sel.click(testvars.MCUI["AdminReviewQueue"])
#                sel.click(testvars.MCTestVariables["ViewMainSiteLink"])
                sel.open(testvars.MCTestVariables["TestSite"])
                sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
                sel.click(testvars.MCTestVariables["ViewAdmin"])
                sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
            else:
                print "None__________None"
Exemple #27
0
def UncheckRequireLoginToSubmitVideo(self,sel):
    NavigateToSettingsPage(self,sel)
    print "Unchecking 'Require Users to Login to Submit a Video' check box..."
    if sel.is_element_present("id_display_submit_button")==False:
        mclib.AppendErrorMessage(self,sel,"Display 'Submit a Video' button check box not found")
    else:
        if sel.is_element_present("id_submission_requires_login")==False:
            mclib.AppendErrorMessage(self,sel,"'Require Users to Login to Submit a Video' check box not found")
        else:
            sel.check("id_display_submit_button")
            sel.uncheck("id_submission_requires_login")
            sel.click("submit_settings")
            print "Done"
            sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
            sel.open(testvars.MCTestVariables["SettingsPage"])
            sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
Exemple #28
0
def ActivateUserAccount(self, sel, email, password):
    print "Checking email for activation link"
    mailUser = email
    mailPassword = password
    mail = imaplib.IMAP4_SSL('imap.gmail.com', 993)
    mail.login(mailUser, mailPassword)
    mail.select('Inbox')
    result, data = mail.uid('search', None,
                            '(HEADER Subject "Finish Signing Up at")')
    latest_email_uid = data[0].split()[-1]
    result, data = mail.uid('fetch', latest_email_uid, '(RFC822)')
    raw_email = data[0][1]
    leadIn = "To activate the account click on the following link or copy-&-paste it in y=\r\nour browser:\r\n"
    temp1 = raw_email.split(leadIn)
    #    print temp1[1]
    #    print "***************"
    leadOut = "\r\n\r\nAfter activation you may login"
    temp2 = temp1[1].split(leadOut)
    #    print temp2[0]
    activationURL = temp2[0].replace('=\r\n', '')
    print "Activation link:"
    print activationURL
    print "Now attempting to activate the account..."
    sel.open(activationURL)
    sel.wait_for_page_to_load(testvars.MCTestVariables["TimeOut"])
    if sel.is_text_present(
            "Your account has been activated! Please log in using the link at the bottom of this page."
    ):
        print "OK"
    else:
        mclib.AppendErrorMessage(self, sel, "Account activation failed")
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
Exemple #30
0
 def test_AddNewAdmin_271(self):
     sel = self.selenium
     # Log in as Admin
     loginlogout.LogInAsAdmin(self, sel)
     # This is information for add user edit fields
     username = "******"
     password = "******"
     email = "*****@*****.**"
     role = "1"  # "1"-Admin, "0"-User
     # This function returns the row number for the desired username
     # on /users page.
     # Returns row number if the us username is found and 0 otherwise.
     if users.UserRow(self, sel, username) != 0:
         print "Duplicate user found. Deleting it..."
         # This function delete user
         users.DeleteUser(self, sel, username, 0)
     # This function add user
     users.AddUser(self, sel, username, email, role, password)
     print "Logging out..."
     # This function log out
     loginlogout.LogOut(self, sel)
     print "Logging in as user: "******"ViewAdmin"]
     ) == True or sel.is_element_present(
             testvars.MCTestVariables["ViewAdminBlueTheme"]) == True:
         print "Logged as Admin"
     else:
         mclib.AppendErrorMessage(
             self, sel,
             "User " + username + " does not have Administrator privileges")