def starter_dialog_translate_from_not_orig(self,sel,from_lang,to_lang='hr'): """Choose the a new translation and translate from a sub that is not the orig lang. Return from_lang This assumes you know the original language and want to edit the original subs. Post-condition: the widget is launched and you will be on step 1 or Edit step """ #Figure out orig lang fail is there isn't a set lang already mslib.wait_for_text_present(self,sel,"This video") if sel.is_element_present(testvars.create_lang_unknown): self.fail("can't make a new translation when video has no orig lang set - test is invalid") else: ol = sel.get_text(testvars.create_lang_known) orig_lang = ol.split("in ")[1] lc = sel.get_value("css=select.to-language option:contains('"+orig_lang+" ')") lang_code = re.sub("\d+$","",lc) if lang_code == from_lang: self.fail("invalid test - from lang "+str(from_lang)+" is the same as the origi lang"+str(orig_lang)) select_video_language(self,sel,sub_lang=to_lang,from_lang=from_lang) time.sleep(5) close_howto_video(self,sel) mslib.wait_for_element_present(self,sel,"css=.unisubs-help-heading") return from_lang
def starter_dialog_translate_from_orig(self,sel,to_lang='hr'): """Choose the a new translation and translate from original lang Return orig_lang This assumes you know the original language and want to edit the original subs. Post-condition: the widget is launched and you will be on step 1 or Edit step """ #Figure out orig lang fail is there isn't a set lang already mslib.wait_for_text_present(self,sel,"This video") sel.select_frame("relative=top") if sel.is_element_present(testvars.create_lang_unknown): self.fail("can't make a new translation when video has no orig lang set - test is invalid") else: time.sleep(5) ol = sel.get_text(testvars.create_lang_known) orig_lang = ol.split("in ")[1] if not sel.is_element_present("css=select.from-language option:contains('"+orig_lang+" ')"): print "orig lang not transcribed - choosing other existing lang" lc = sel.get_value("css=select.from-language option") else: lc = sel.get_value("css=select.from-language option:contains('"+orig_lang+" ')") lang_code = re.sub("\d+$","",lc) #gives only the letters of the value field. from_code = re.sub("\D","",lc) #gives only the number - used in from pulldown. select_video_language(self,sel,sub_lang=to_lang,from_lang=from_code) time.sleep(5) close_howto_video(self,sel) mslib.wait_for_element_present(self,sel,"css=div.unisubs-help-heading") return orig_lang
def test_613(self): """Submit a video and add to team. http://litmus.pculture.org/show_test.cgi?id=613. """ sel = self.selenium sel.set_timeout(testvars.timeout) #login website.SiteLogIn(self,sel,testvars.siteuser,testvars.passw) #create team team = "miro"+time.strftime("%m%d%H%M%S", time.gmtime()) team_logo_path = os.path.join(testvars.MSTestVariables["DataDirectory"],"sheep.png") website.open_teams_page(self,sel) sel.click(testvars.start_team) sel.wait_for_page_to_load(testvars.timeout) website.create_team(self,sel,team,team_logo_path) #submit video sel.window_maximize() test_video_url = website.submit_random_youtube(self,sel) print test_video_url mslib.wait_for_element_present(self,sel,"css=span.sort_label strong:contains('Add video')") vid_title = sel.get_text(testvars.vid_title) #add video to team and verify values teamli = "add/video/"+team sel.click(testvars.video_add_to_team) ## sel.click_at("css=span.sort_label strong:contains('Add video')","") sel.click_at("css=a[href*='"+teamli+"']","") sel.wait_for_page_to_load(testvars.timeout) print "verifying the inital add page" if sel.is_element_present("css=.errorlist")== True: print "error adding video to team" self.fail() else: mslib.wait_for_text_present(self,sel,"Video language") sel.select("id_language", "value=en") sel.click(testvars.teams_save) sel.wait_for_page_to_load(testvars.timeout) self.assertTrue(sel.is_element_present("css=li.active a:contains('"+team+"')")) sel.click(testvars.teams_video_tab) sel.wait_for_page_to_load(testvars.timeout) print "verifying team videos list" self.assertTrue(sel.is_element_present("css=tr.video-container td a[href*='"+test_video_url+"info/']"),"test_video_url error") # self.assertTrue(sel.is_element_present("css=tr.video-container td:contains('"+vid_title[0:10]+"')"),"vid_title error") # delete the video from the team sel.click("css=td a:contains('"+vid_title[0:10]+"') +div +div +div.small.grey a.remove-video") self.failUnless(re.search(r"^Remove this video[\s\S]$", sel.get_confirmation())) # logout sel.click(testvars.WebsiteUI["Logout_Button"])
def starter_dialog_fork(self,sel,to_lang='hr'): """Choose the a new translation and translate from original lang Return orig_lang This assumes you know the original language and want to edit the original subs. Post-condition: the widget is launched and you will be on step 1 or Edit step """ #Figure out orig lang fail is there isn't a set lang already mslib.wait_for_text_present(self,sel,"This video") if sel.is_element_present(testvars.create_lang_unknown): self.fail("can't make a new translation when video has no orig lang set - test is invalid") else: ol = sel.get_text(testvars.create_lang_known) orig_lang = ol.split("in ")[1] select_video_language(self,sel,sub_lang=to_lang,from_lang='forkk') time.sleep(5) close_howto_video(self,sel) mslib.wait_for_element_present(self,sel,"css=.unisubs-activestep") return orig_lang
def select_video_language(self,sel,vid_lang="en",sub_lang="en-gb",from_lang='forkk'): time.sleep(5) mslib.wait_for_element_present(self,sel,testvars.WidgetUI["Select_language"]) sel.select_frame("relative=top") mslib.wait_for_text_present(self,sel,"Subtitle into") if sel.is_element_present(testvars.create_lang_unknown): # Don't know the video lang so choose for 1st time subs. sel.select(testvars.create_lang_unknown, "value=regexp:^"+str(vid_lang)) if sel.is_element_present(testvars.create_subtitle_into): sel.select("css=select.to-language", "value=regexp:^"+str(sub_lang)) print "edit orig subs, orig: "+str(vid_lang)+" to: "+str(sub_lang) else: mslib.wait_for_element_present(self,sel,testvars.create_lang_known) sel.select("css=select.to-language", "value=regexp:^"+str(sub_lang)) print "subbing into: "+str(sub_lang) time.sleep(2) if sel.is_element_present("css=select.from-language") == True: sel.select("css=select.from-language", "value=regexp:^"+str(from_lang)) print "selected video language, from: "+str(from_lang) time.sleep(1) sel.click("css=div.unisubs-modal-lang div a.unisubs-green-button:contains('Continue')")
def test_613(self): """Submit a video and add to team. http://litmus.pculture.org/show_test.cgi?id=613. """ sel = self.selenium sel.set_timeout(testvars.timeout) #login website.SiteLogIn(self, sel, testvars.siteuser, testvars.passw) #create team team = "miro" + time.strftime("%m%d%H%M%S", time.gmtime()) team_logo_path = os.path.join( testvars.MSTestVariables["DataDirectory"], "sheep.png") website.open_teams_page(self, sel) sel.click(testvars.start_team) sel.wait_for_page_to_load(testvars.timeout) website.create_team(self, sel, team, team_logo_path) #submit video sel.window_maximize() test_video_url = website.submit_random_youtube(self, sel) print test_video_url mslib.wait_for_element_present( self, sel, "css=span.sort_label strong:contains('Add video')") vid_title = sel.get_text(testvars.vid_title) #add video to team and verify values teamli = "add/video/" + team sel.click(testvars.video_add_to_team) ## sel.click_at("css=span.sort_label strong:contains('Add video')","") sel.click_at("css=a[href*='" + teamli + "']", "") sel.wait_for_page_to_load(testvars.timeout) print "verifying the inital add page" if sel.is_element_present("css=.errorlist") == True: print "error adding video to team" self.fail() else: mslib.wait_for_text_present(self, sel, "Video language") sel.select("id_language", "value=en") sel.click(testvars.teams_save) sel.wait_for_page_to_load(testvars.timeout) self.assertTrue( sel.is_element_present("css=li.active a:contains('" + team + "')")) sel.click(testvars.teams_video_tab) sel.wait_for_page_to_load(testvars.timeout) print "verifying team videos list" self.assertTrue( sel.is_element_present("css=tr.video-container td a[href*='" + test_video_url + "info/']"), "test_video_url error") # self.assertTrue(sel.is_element_present("css=tr.video-container td:contains('"+vid_title[0:10]+"')"),"vid_title error") # delete the video from the team sel.click("css=td a:contains('" + vid_title[0:10] + "') +div +div +div.small.grey a.remove-video") self.failUnless( re.search(r"^Remove this video[\s\S]$", sel.get_confirmation())) # logout sel.click(testvars.WebsiteUI["Logout_Button"])
def open_starter_dialog(self,sel): sel.click(testvars.WebsiteUI["NewTranslation_menuitem"]) mslib.wait_for_element_present(self,sel,testvars.WidgetUI["Select_language"]) mslib.wait_for_text_present(self,sel,"This video") time.sleep(10)