Skip to content

Commit

Permalink
Merge pull request mozilla#106 from tobbi/sumo-fixes
Browse files Browse the repository at this point in the history
Adding POM methods that allow for setting a topic and a product
  • Loading branch information
stephendonner committed Sep 4, 2012
2 parents 9129bf9 + f97bf0a commit 2fa9629
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pages/desktop/knowledge_base_article.py
Expand Up @@ -106,6 +106,8 @@ class KnowledgeBaseEditArticle(KnowledgeBase):
_article_keywords_box_locator = (By.ID, 'id_keywords')
_article_summary_box_locator = (By.ID, 'id_summary')
_article_content_box_locator = (By.ID, 'id_content')
_article_topic_locator = (By.CSS_SELECTOR, 'input[name=topics]')
_article_product_locator = (By.CSS_SELECTOR, 'input[name=products]')
_article_submit_btn_locator = (By.CSS_SELECTOR, '.btn-submit')
_comment_box_locator = (By.ID, 'id_comment')
_comment_submit_btn_locator = (By.CSS_SELECTOR, 'input[value="Submit"]')
Expand All @@ -125,6 +127,8 @@ def edit_article(self, article_info_dict):
self.set_article_keyword(article_info_dict['keyword'])
self.set_article_summary(article_info_dict['summary'])
self.set_article_content(article_info_dict['content'])
self.check_article_topic(1)
self.check_article_product(1)
self.submit_article()
return self.set_article_comment_box()

Expand All @@ -142,6 +146,14 @@ def set_article_content(self, content):
element = self.selenium.find_element(*self._article_content_box_locator)
element.clear()
element.send_keys(content)

def check_article_topic(self, index):
index = index - 1
self.selenium.find_elements(*self.article_topic_locator)[index].click()

def check_article_product(self, index):
index = index - 1
self.selenium.find_elements(*self.article_product_locator)[index].click()

def set_article_comment_box(self, comment='automated test'):
self.selenium.find_element(*self._comment_box_locator).send_keys(comment)
Expand Down
12 changes: 12 additions & 0 deletions pages/desktop/knowledge_base_new_article.py
Expand Up @@ -22,6 +22,8 @@ class KnowledgeBaseNewArticle(Base):
_article_summary_box_locator = (By.ID, 'id_summary')
_article_content_box_locator = (By.ID, 'id_content')
_article_slug_box_locator = (By.ID, 'id_slug')
_article_topic_locator = (By.CSS_SELECTOR, 'input[name=topics]')
_article_product_locator = (By.CSS_SELECTOR, 'input[name=products]')
_article_preview_btn_locator = (By.CSS_SELECTOR, 'div.submit > .btn-preview')
_article_preview_content_locator = (By.CSS_SELECTOR, 'div#preview > div#doc-content')
_article_submit_btn_locator = (By.CSS_SELECTOR, 'input[value="Submit for Review"]')
Expand All @@ -38,6 +40,8 @@ def set_article(self, article_info_dict):
self.set_article_keyword(article_info_dict['keyword'])
self.set_article_summary(article_info_dict['summary'])
self.set_article_content(article_info_dict['content'])
self.check_article_topic(1)
self.check_article_product(1)

def set_article_title(self, title):
self.selenium.find_element(*self._article_title_box_locator).send_keys(title)
Expand All @@ -49,6 +53,14 @@ def set_article_category(self, category):
select_box = Select(self.selenium.find_element(*self._article_category_menu_locator))
select_box.select_by_visible_text(category)

def check_article_topic(self, index):
index = index - 1
self.selenium.find_elements(*self.article_topic_locator)[index].click()

def check_article_product(self, index):
index = index - 1
self.selenium.find_elements(*self.article_product_locator)[index].click()

def set_article_keyword(self, keyword):
self.selenium.find_element(*self._article_keywords_box_locator).send_keys(keyword)

Expand Down

0 comments on commit 2fa9629

Please sign in to comment.