def test_forum_reply_logged_out(self): """Tests to ensure Reply link is not available when logged-out """ sel = self.selenium forums_page_obj = forums_page.ForumsPage(sel) ''' go to forums page ''' forums_page_obj.go_to_forums_cat_list_page() forums_page_obj.click(forums_page_obj.first_cat_forum_link, True) counter = 0 unlocked_not_found = True while (unlocked_not_found and counter < 11): ''' click on a thread starting with the first and work your way down the list until you have checked 10 thread and none of them are unlocked ''' counter = counter + 1 if (forums_page_obj.is_element_present( forums_page_obj.locked_thread_format % (counter))): continue else: unlocked_not_found = False forums_page_obj.click( (forums_page_obj.unlocked_thread_format % (counter)), True) self.failIf(sel.is_element_present(forums_page_obj.reply_link), "Reply not disabled")
def test_forum_new_post(self): """Post a new thread in the KB articles forums""" sel = self.selenium login_page_obj = login_page.LoginPage(sel) forums_page_obj = forums_page.ForumsPage(sel) user_info = sumo_test_data.SUMOtestData().getUserInfo(0) uname = user_info['username'] pwd = user_info['password'] timestamp = sel.get_eval("new Date().getTime()") thread_title = "Litmus 7829 test" + timestamp thread_text = "Litmus QA 7829 Testcase Test Msg" ''' Login ''' login_page_obj.log_in(uname, pwd) ''' Post a new thread ''' forums_page_obj.open(forums_page_obj.kb_articles_forum_url) forums_page_obj.post_new_thread_first_cat(thread_title, thread_text) time.sleep(5) self.failUnless(sel.is_text_present(thread_text)) # Verify post title forums_page_obj.open(forums_page_obj.kb_articles_forum_url) self.failUnless(sel.is_text_present(thread_title)) ''' Logout ''' forums_page_obj.log_out()
def test_forum_pagination_on_prod(self, testsetup): """Post a new thread and reply to the thread Check pagination after 20 posts. This test is suppossed to be run only on Production site. It Posts in the auto-test forums which is only viewable by certain users Note: This test will not run locally by itself. It will only run in BFT suite. """ thread_num = str(random.randint(100, 10000)) thread_title = 'test_thread_' + thread_num thread_text = 'some text' login_page_obj = login_page.LoginPage(testsetup) forums_page_obj = forums_page.ForumsPage(testsetup) login_page_obj.log_in_as_admin() # Post a new thread # this forum is only only viewable by certain users, # so posting to it on Prod is allowed. forums_page_obj.open( 'https://support.mozilla.com/en-US/forums/auto-test') forums_page_obj.post_new_thread_first_cat(thread_title, thread_text) assert (forums_page_obj.is_text_present(thread_text)) forums_page_obj.log_out()
def test_forum_deletion(self): '''Checks bug 569310 (accidental forum deletion)''' sel = self.selenium login_page_obj = login_page.LoginPage(sel) forums_page_obj = forums_page.ForumsPage(sel) user_adm = 1 thread_num = str(random.randint(100, 10000)) user_info = sumo_test_data.SUMOtestData().getUserInfo(user_adm) uname = user_info['username'] pwd = user_info['password'] ''' Login ''' login_page_obj.log_in(uname, pwd) ''' Post a new thread ''' thread_title = 'test_thread_' + thread_num thread_text = 'some text' ''' Post a new thread ''' forums_page_obj.go_to_forums_cat_list_page() forums_page_obj.click(forums_page_obj.first_cat_forum_link,True) forums_page_obj.post_new_thread_first_cat(thread_title,thread_text) thread_loc = str(sel.get_location()) thread_loc_arr = thread_loc.split('/') url1 = thread_loc_arr[len(thread_loc_arr) - 2] url2 = thread_loc_arr[len(thread_loc_arr) - 1] thread_loc = vars.ConnectionParameters.baseurl_ssl+'/en-US/forums/%s/%s' % (url1, url2) num_of_posts = 5 for counter in range(1, (num_of_posts + 1)): thread_reply = 'some reply %s' % str(int(thread_num) + counter) forums_page_obj.post_reply(thread_loc, thread_reply) location = sel.get_location() p = re.compile('post-[0-9]*') postString = p.search(location) postNum = postString.group()[5:] # delete link of second to last post post_to_delete_link = "css=li#post-%s > div > div > a:nth-child(2)" % str(int(postNum) - 1) forums_page_obj.wait_for_element_present(post_to_delete_link) sel.click(post_to_delete_link) sel.wait_for_page_to_load(vars.ConnectionParameters.page_load_timeout) #confirmation dialogue for deletion sel.click("css=form > input[type='submit']") sel.wait_for_page_to_load(vars.ConnectionParameters.page_load_timeout) sel.open(thread_loc) self.failUnless(sel.is_text_present(thread_title))
def test_forum_b_goto_post_after_reply(self): """Check if forum redirects to post after replying.""" sel = self.selenium login_page_obj = login_page.LoginPage(sel) forums_page_obj = forums_page.ForumsPage(sel) thread_reply = 'some reply ' + str(int(self.thread_num)) user_info = sumo_test_data.SUMOtestData().getUserInfo(0) uname = user_info['username'] pwd = user_info['password'] ''' login ''' login_page_obj.log_in(uname, pwd) forums_page_obj.post_reply(thread_loc, thread_reply) post_url = forums_page_obj.get_url_current_page() self.failUnless(('#post-' in post_url), "Not redirecting to post (not in url)")
def test_forum_deletion(self, testsetup): '''Checks bug 569310 (accidental forum deletion)''' login_page_obj = login_page.LoginPage(testsetup) forums_page_obj = forums_page.ForumsPage(testsetup) thread_num = str(random.randint(100, 10000)) login_page_obj.log_in_as_admin() # Post a new thread thread_title = 'test_thread_%s' % thread_num thread_text = 'some text' forums_page_obj.go_to_forums_cat_list_page() forums_page_obj.click(forums_page_obj.first_cat_forum_link, True) forums_page_obj.post_new_thread_first_cat(thread_title, thread_text) thread_loc = str(forums_page_obj.get_url_current_page()) thread_loc_arr = thread_loc.split('/') url1 = thread_loc_arr[len(thread_loc_arr) - 2] url2 = thread_loc_arr[len(thread_loc_arr) - 1] thread_loc = '%s/en-US/forums/%s/%s' % (testsetup.base_url_ssl, url1, url2) num_of_posts = 5 for counter in range(1, (num_of_posts + 1)): thread_reply = 'some reply %s' % str(int(thread_num) + counter) forums_page_obj.post_reply(thread_loc, thread_reply) location = forums_page_obj.get_url_current_page() p = re.compile('post-[0-9]*') postString = p.search(location) postNum = postString.group()[5:] # delete link of second to last post post_to_delete_link = "css=li#post-%s > div > div > a:nth-child(2)" % str( int(postNum) - 1) forums_page_obj.wait_for_element_present(post_to_delete_link) forums_page_obj.click(post_to_delete_link, True) #confirmation dialogue for deletion forums_page_obj.click("css=form > input[type='submit']", True) forums_page_obj.open(thread_loc) assert forums_page_obj.is_text_present(thread_title)
def test_forum_new_post(self, testsetup): """Post a new thread in the KB articles forums""" login_page_obj = login_page.LoginPage(testsetup) forums_page_obj = forums_page.ForumsPage(testsetup) timestamp = str(datetime.datetime.now()) thread_title = "Litmus 7829 test" + timestamp thread_text = "Litmus QA 7829 Testcase Test Msg" login_page_obj.log_in_as_non_admin() forums_page_obj.open(forums_page_obj.kb_articles_forum_url) forums_page_obj.post_new_thread_first_cat(thread_title, thread_text) assert forums_page_obj.is_text_present(thread_text) # Verify post title forums_page_obj.open(forums_page_obj.kb_articles_forum_url) assert forums_page_obj.is_text_present(thread_title) forums_page_obj.log_out()
def test_forum_pagination_on_prod(self): """Post a new thread and reply to the thread Check pagination after 20 posts. This test is suppossed to be run only on Production site. It Posts in the auto-test forums which is only viewable by certain users Note: This test will not run locally by itself. It will only run in BFT suite. """ thread_num = str(random.randint(100, 10000)) thread_title = 'test_thread_' + thread_num thread_text = 'some text' self.selenium.stop() self.selenium = selenium(vars.ConnectionParameters.server, vars.ConnectionParameters.port, vars.ConnectionParameters.browser, 'https://support.mozilla.com') self.selenium.start() self.timeout = vars.ConnectionParameters.page_load_timeout self.selenium.set_timeout(self.timeout) sel = self.selenium login_page_obj = login_page.LoginPage(sel) forums_page_obj = forums_page.ForumsPage(sel) user_info = sumo_test_data.SUMOtestData().getUserInfo(1) uname = user_info['username'] pwd = user_info['password'] login_page_obj.log_in(uname, pwd) # Post a new thread # this forum is only only viewable by certain users, # so posting to it on Prod is allowed. forums_page_obj.open( 'https://support.mozilla.com/en-US/forums/auto-test') forums_page_obj.post_new_thread_first_cat(thread_title, thread_text) self.failUnless(sel.is_text_present(thread_text)) ''' Logout ''' forums_page_obj.log_out()
def test_forum_reply_logged_out(self, testsetup): """Tests to ensure Reply link is not available when logged-out """ forums_page_obj = forums_page.ForumsPage(testsetup) forums_page_obj.go_to_forums_cat_list_page() forums_page_obj.click(forums_page_obj.first_cat_forum_link, True) counter = 0 unlocked_not_found = True while unlocked_not_found and counter < 11: # click on a thread starting with the first and # work your way down the list until you have checked 10 # thread and none of them are unlocked counter += 1 if forums_page_obj.is_element_present( forums_page_obj.locked_thread_format % (counter)): continue else: unlocked_not_found = False forums_page_obj.click( (forums_page_obj.unlocked_thread_format % (counter)), True) assert not forums_page_obj.is_element_present(forums_page_obj.reply_link),\ "Reply not disabled"
def test_forum_a_pagination(self): """Post a new thread and reply to the thread Check pagination after 20 posts. """ sel = self.selenium login_page_obj = login_page.LoginPage(sel) forums_page_obj = forums_page.ForumsPage(sel) user_info = sumo_test_data.SUMOtestData().getUserInfo(0) uname = user_info['username'] pwd = user_info['password'] ''' Login ''' login_page_obj.log_in(uname, pwd) time.sleep(5) #base_url_secure = sel.get_location()[:-10] ''' Post a new thread ''' forums_page_obj.go_to_forums_cat_list_page() forums_page_obj.click(forums_page_obj.first_cat_forum_link, True) forums_page_obj.post_new_thread_first_cat(self.thread_title, self.thread_text) global thread_loc thread_loc = str(sel.get_location()) thread_loc_arr = thread_loc.split('/') url1 = thread_loc_arr[len(thread_loc_arr) - 2] url2 = thread_loc_arr[len(thread_loc_arr) - 1] thread_loc = vars.ConnectionParameters.baseurl_ssl + '/en-US/forums/%s/%s' % ( url1, url2) '''Post over 20 replies''' '''Each page takes 20 posts''' num_of_posts = 21 for counter in range(1, (num_of_posts + 1)): thread_reply = 'some reply ' + str(int(self.thread_num) + counter) forums_page_obj.post_reply(thread_loc, thread_reply) self.failUnless( sel.is_text_present(thread_reply), "%s not present on %s" % (thread_reply, thread_loc)) '''Once there are over 20 posts, verify pagination''' '''Verify for new page/previous page links ''' if (counter > 20 and counter % 20 == 1): self.failUnless( sel.is_element_present(forums_page_obj.pagination_link), "Pagination not present at %s" % sel.get_location()) '''If counter=41 then previous page = page 2 ''' prev_page_num = int((counter - 1) / 20) prev_page_link = thread_loc prev_page_link += '?page=' + str(prev_page_num) self.failUnless( sel.is_element_present('css=a[href*=' + prev_page_link + ']'), "Prev page link of %s not present at %s" % (prev_page_link, sel.get_location())) sel.click('css=a[href=' + prev_page_link + ']') sel.wait_for_page_to_load( vars.ConnectionParameters.page_load_timeout) self.failUnless( sel.is_element_present(forums_page_obj.next_page_link)) next_page_num = prev_page_num + 1 next_page_link = thread_loc next_page_link += '?page=' + str(next_page_num) self.failUnless( sel.is_element_present('css=a[href=' + next_page_link + ']'), "next page link not present")
def test_forum_pagination_on_prod(self): """Post a new thread and reply to the thread Check pagination after 20 posts. This test is suppossed to be run only on Production site. It Posts in the auto-test forums which is only viewable by certain users Note: This test will not run locally by itself. It will only run in BFT suite. """ self.selenium.stop() self.selenium = selenium(vars.ConnectionParameters.server, vars.ConnectionParameters.port, vars.ConnectionParameters.browser, 'https://support.mozilla.com') self.selenium.start() self.timeout = vars.ConnectionParameters.page_load_timeout self.selenium.set_timeout(self.timeout) sel = self.selenium #sel.open('https://support.mozilla.com') login_page_obj = login_page.LoginPage(sel) forums_page_obj = forums_page.ForumsPage(sel) user_info = sumo_test_data.SUMOtestData().getUserInfo(1) uname = user_info['username'] pwd = user_info['password'] ''' Login ''' login_page_obj.log_in(uname, pwd) time.sleep(5) #base_url_secure = sel.get_location()[:-10] ''' Post a new thread ''' """this forum is only only viewable by certain users, so posting to it on Prod is allowed. """ sel.open('https://support.mozilla.com/en-US/forums/auto-test') forums_page_obj.post_new_thread_first_cat(self.thread_title, self.thread_text) #global thread_loc self.thread_loc = str(sel.get_location()) thread_loc_arr = self.thread_loc.split('/') url1 = thread_loc_arr[len(thread_loc_arr) - 2] url2 = thread_loc_arr[len(thread_loc_arr) - 1] thread_loc = "https://support.mozilla.com/en-US/forums/%s/%s" % (url1, url2) '''Post over 20 replies''' '''Each page takes 20 posts''' num_of_posts = 21 for counter in range(1, (num_of_posts + 1)): thread_reply = 'some reply ' + str(int(self.thread_num) + counter) forums_page_obj.post_reply(thread_loc, thread_reply) self.failUnless( sel.is_text_present(thread_reply), "%s not present on %s" % (thread_reply, thread_loc)) '''Once there are over 20 posts, verify pagination''' '''Verify for new page/previous page links ''' if (counter > 20 and counter % 20 == 1): self.failUnless( sel.is_element_present(forums_page_obj.pagination_link), "Pagination not present at %s" % sel.get_location()) '''If counter=41 then previous page = page 2 ''' prev_page_num = int((counter - 1) / 20) prev_page_link = thread_loc prev_page_link += '?page=' + str(prev_page_num) self.failUnless( sel.is_element_present('css=a[href*=' + prev_page_link + ']'), "Prev page link of %s not present at %s" % (prev_page_link, sel.get_location())) sel.click('css=a[href=' + prev_page_link + ']') sel.wait_for_page_to_load( vars.ConnectionParameters.page_load_timeout) self.failUnless( sel.is_element_present(forums_page_obj.next_page_link)) next_page_num = prev_page_num + 1 next_page_link = thread_loc next_page_link += '?page=' + str(next_page_num) self.failUnless( sel.is_element_present('css=a[href=' + next_page_link + ']'), "next page link not present")