Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'klrmn/wd2' into webdriver
Browse files Browse the repository at this point in the history
Conflicts:
	pages/desktop/support_home_page.py
  • Loading branch information
Zac authored and Zac committed Mar 14, 2012
2 parents 9808351 + 7ca0acb commit 9051a23
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 58 deletions.
4 changes: 2 additions & 2 deletions pages/desktop/contributors_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def click_top_visited_article_link(self):

def click_this_week(self):
self.selenium.find_element(*self._this_week_button_locator).click()
self.wait_for_element_come_and_go(*self._documents_table_busy_locator)
self.wait_for_ajax()

def click_all_time(self):
self.selenium.find_element(*self._all_time_button_locator).click()
self.wait_for_element_come_and_go(self._documents_table_busy_locator)
self.wait_for_ajax()
39 changes: 24 additions & 15 deletions pages/desktop/knowledge_base_article.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ def vote_not_helpful(self):
self.wait_for_element_come_and_go(*self._helpful_form_busy_locator)

# each user can only vote once per article
@property
def can_vote(self):
return self.is_element_present(*self._helpful_locator)

# for providing some random feedback about the article
def vote(self):
if (self.can_vote()):
if self.can_vote:
import random
helpful = random.randint(0,1)
if (helpful):
Expand Down Expand Up @@ -106,27 +107,27 @@ def edit_article(self, article_info_dict):
self.set_article_comment_box()

def set_article_keyword(self, keyword):
we = self.selenium.find_element(*self._article_keywords_box_locator)
we.clear()
we.send_keys(keyword)
element = self.selenium.find_element(*self._article_keywords_box_locator)
element.clear()
element.send_keys(keyword)

def set_article_summary(self, summary):
we = self.selenium.find_element(*self._article_summary_box_locator)
we.clear()
we.send_keys(summary)
element = self.selenium.find_element(*self._article_summary_box_locator)
element.clear()
element.send_keys(summary)

def set_article_content(self, content):
we = self.selenium.find_element(*self._article_content_box_locator)
we.clear()
we.send_keys(content)
element = self.selenium.find_element(*self._article_content_box_locator)
element.clear()
element.send_keys(content)

def set_article_comment_box(self, comment='automated test'):
self.selenium.find_element(*self._comment_box_locator).send_keys(comment)
self.selenium.find_element(*self._comment_submit_btn_locator).click()

def submit_article(self):
self.selenium.find_element(*self._article_submit_btn_locator).click()
self.wait_for_element_present(self._comment_box_locator)
self.wait_for_element_present(*self._comment_box_locator)


class KnowledgeBaseTranslate(KnowledgeBase):
Expand Down Expand Up @@ -169,7 +170,8 @@ class KnowledgeBaseShowHistory(KnowledgeBase):
_revision_history_language_locator = (By.CSS_SELECTOR, 'div.choice-list ul li > span')

#history of the test
_top_revision_comment = (By.CSS_SELECTOR, '#revision-list li:nth-child(2) > div.comment')
_top_revision_comment = (By.CSS_SELECTOR, \
'#revision-list li:nth-child(2) > div.comment')

_show_chart_link_locator = (By.ID, 'show-chart')
_helpfulness_chart_locator = (By.ID, 'helpful-chart')
Expand All @@ -182,15 +184,18 @@ def is_the_current_page(self):
WebDriverWait(self.selenium, self.timeout).until(lambda s: s.title)

if re.search(self._page_title, self.selenium.title) is None:
raise Exception("Expected page title to be: '" + self._page_title + "' but it was: '" + actual_title + "'")
raise Exception("Expected page title to be: '" + self._page_title \
+ "' but it was: '" + actual_title + "'")
else:
return True


@property
def is_helpfulness_chart_visible(self):
# Because of bug 723575 there are two element checks to assert that the graph has actually loaded
return self.is_visible(*self._helpfulness_chart_locator) and self.is_visible(*self._helpfulness_chart_graph_locator)
# Because of bug 723575 there are two element checks to assert that
# the graph has actually loaded
return self.is_element_visible(*self._helpfulness_chart_locator) \
and self.is_element_visible(*self._helpfulness_chart_graph_locator)

def delete_entire_article_document(self):
self.click_delete_entire_article_document()
Expand All @@ -202,6 +207,10 @@ def click_delete_entire_article_document(self):
def click_delete_confirmation_button(self):
self.selenium.find_element(*self._delete_confirmation_btn_locator).click()

def click_show_helpfulness_chart(self):
self.selenium.find_element(*self._show_chart_link_locator).click()
self.wait_for_ajax()

@property
def most_recent_revision_comment(self):
self.wait_for_element_visible(*self._top_revision_comment)
Expand Down
3 changes: 2 additions & 1 deletion pages/desktop/knowledge_base_new_article.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ def click_article_preview_button(self):
self.selenium.find_element(*self._article_preview_btn_locator).click()
self.wait_for_element_present(*self._article_preview_content_locator)

def get_article_preview_text(self):
@property
def article_preview_text(self):
return self.selenium.find_element(*self._article_preview_content_locator).text
8 changes: 5 additions & 3 deletions pages/desktop/questions_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ def click_sort_by_unsolved_questions(self):
def click_sort_by_no_replies_questions(self):
self.selenium.find_element(*self._sort_no_replies_link_locator).click()

@property
def are_questions_present(self):
return self.is_element_present(*self._questions_list_block_locator)

@property
def get_questions_count(self):
def questions_count(self):
return len(self.selenium.find_elements(*self._questions_list_locator))

def get_sorted_list_filter_text(self, question_number):
def sorted_list_filter_text(self, question_number):
return self.selenium.find_elements(*self._questions_list_locator)[question_number - 1].find_element(*self._solved_or_unsolved_text_locator).text


Expand Down Expand Up @@ -101,7 +102,8 @@ def fill_up_questions_form(self, q_text='details', q_site='www.example.com', q_t
self.selenium.find_element(*self._q_trouble_box_locator).send_keys(q_trouble)
self.selenium.find_element(*self._q_post_button_locator).click()

def get_sorted_list_filter_text(self, question_number):
@property
def sorted_list_filter_text(self, question_number):
return self.selenium.find_elements(*self._questions_list_locator)[question_number - 1].find_element(*self._solved_or_unsolved_text_locator).text


Expand Down
4 changes: 0 additions & 4 deletions pages/desktop/refine_search_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ def do_search_on_discussion_forums(self, search_query, search_page_obj):
self.selenium.find_element(*self._search_button_disc).click()
search_page_obj.is_the_current_page

# not used
# def is_kb_cat_checked(self):
# return self.selenium.find_element(*self._kb_cat_check_box).is_checked

@property
def search_result_count(self):
return len(self.selenium.find_elements(*self._search_results_list))
6 changes: 2 additions & 4 deletions pages/desktop/search_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ def do_search_on_search_box(self, search_query):
def get_search_box_value(self):
return self.selenium.find_element(*self._search_box).value

# not used
# def is_search_available(self):
# return not self.selenium.is_text_present(self._search_unavailable_msg)

@property
def is_result_present(self):
return self.is_element_present(*self._result_div)

@property
def are_ten_results_present(self):
return len(self.selenium.find_elements(*self._results_list_locator)) == 10

Expand Down
3 changes: 2 additions & 1 deletion pages/desktop/support_home_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class SupportHomePage(Base):
web elements and methods that can be
performed on them.
"""
_page_title = 'Firefox Support Home Page'

_page_title = 'Firefox Support Home Page | Firefox Help'
_home_url = '/en-US/home'

_main_search_box = (By.ID, 'q')
Expand Down
27 changes: 7 additions & 20 deletions pages/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def page_title(self):

def refresh(self):
self.selenium.refresh()
#self.selenium.get(self.selenium.current_url)

def open(self, url_fragment):
self.selenium.get(self.base_url + url_fragment)
Expand Down Expand Up @@ -77,36 +76,24 @@ def wait_for_element_present(self, *locator):
while not self.is_element_present(*locator):
time.sleep(1)
count += 1
if count == self.timeout / 1000:
if count == self.timeout:
raise Exception(*locator + ' has not loaded')

def wait_for_element_not_present(self, *locator):
count = 0
while self.is_element_present(*locator):
time.sleep(1)
count += 1
if count == self.timeout / 1000:
raise Exception(*locator + ' is still present')

def wait_for_element_visible(self, *locator):
count = 0
while not self.is_element_visible(*locator):
time.sleep(1)
count += 1
if count == self.timeout / 1000:
if count == self.timeout:
raise Exception(*locator + " is not visible")

def wait_for_element_not_visible(self, *locator):
def wait_for_ajax(self):
count = 0
while self.is_element_visible(*locator):
while count < self.timeout:
time.sleep(1)
count += 1
if count == self.timeout / 1000:
raise Exception(*locator + " is still visible")

def wait_for_element_come_and_go(self, *locator):
self.wait_for_element_present(*locator)
self.wait_for_element_not_present(*locator)
if self.selenium.execute_script("return jQuery.active == 0"):
return
raise Exception("Wait for AJAX timed out after %s seconds" % count)

def get_user_name(self, user='default'):
credentials = self.testsetup.credentials[user]
Expand Down
2 changes: 1 addition & 1 deletion tests/desktop/test_article_create_edit_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_that_article_can_be_previewed_before_submitting(self, mozwebqa):
article_info_dict = self._create_new_generic_article(kb_new_article)

kb_new_article.click_article_preview_button()
actual_preview_text = kb_new_article.get_article_preview_text()
actual_preview_text = kb_new_article.article_preview_text

Assert.equal(article_info_dict['content'], actual_preview_text)

Expand Down
12 changes: 6 additions & 6 deletions tests/desktop/test_questions_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def test_that_questions_sorts_correctly_by_filter_equal_to_solved(self, mozwebqa
questions_pg.go_to_forum_questions_page()
questions_pg.click_sort_by_solved_questions()
# if there are no questions in the list then skip the test
if not questions_pg.are_questions_present():
if not questions_pg.are_questions_present:
pytest.skip("No questions present for filter=%s" % expected_sorted_text)
num_of_questions = questions_pg.get_questions_count
num_of_questions = questions_pg.questions_count

for counter in range(num_of_questions):
actual_sorted_text = questions_pg.get_sorted_list_filter_text(counter + 1)
actual_sorted_text = questions_pg.sorted_list_filter_text(counter + 1)
Assert.equal(actual_sorted_text, expected_sorted_text)

@pytest.mark.fft
Expand All @@ -43,11 +43,11 @@ def test_that_questions_sorts_correctly_by_filter_equal_to_no_replies(self, mozw
questions_pg.go_to_forum_questions_page()
questions_pg.click_sort_by_no_replies_questions()
# if there are no questions in the list then skip the test
if not questions_pg.are_questions_present():
if not questions_pg.are_questions_present:
pytest.skip("No questions present for filter=%s" % expected_sorted_text)
num_of_questions = questions_pg.get_questions_count
num_of_questions = questions_pg.questions_count

for counter in range(num_of_questions):
index = counter + 1
actual_sorted_text = questions_pg.get_sorted_list_filter_text(index)
actual_sorted_text = questions_pg.sorted_list_filter_text(index)
Assert.equal(actual_sorted_text, expected_sorted_text)
2 changes: 1 addition & 1 deletion tests/desktop/test_view_helpfulness_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_view_helpfulness_chart(self, mozwebqa):
sumo_homepage.go_to_support_home_page()
sumo_homepage.sign_in();
contrib_page = sumo_homepage.click_knowledge_base_dashboard_link()
Assert.true(contrib_page.is_the_current_page)
contrib_page.is_the_current_page
contrib_page.click_all_time()
kb_article = contrib_page.click_top_visited_article_link()

Expand Down

0 comments on commit 9051a23

Please sign in to comment.