/pages/desktop/forums_page.py

https://github.com/AlinT/sumo-tests · Python · 61 lines · 43 code · 8 blank · 10 comment · 2 complexity · 8d36d4168f55dfeb2237f73c0fbe2dba MD5 · raw file

  1. #!/usr/bin/env python
  2. # This Source Code Form is subject to the terms of the Mozilla Public
  3. # License, v. 2.0. If a copy of the MPL was not distributed with this
  4. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  5. from pages.desktop.base import Base
  6. class ForumsPage(Base):
  7. """
  8. The Firefox Forums Page contains
  9. web elements and methods that can be
  10. performed on them. The page lists different
  11. categories of forums: SUMO community/Off-topic etc.
  12. """
  13. _page_title = 'Forums'
  14. _first_cat_forum_link = "css=div.name > a"
  15. _post_new_thread_link = "new-thread"
  16. _thread_title_box = "css=input#id_title"
  17. _thread_content_box = "id_content"
  18. _post_button = "css=input[value='Post']"
  19. _cancel_link = "link=Cancel"
  20. _reply_button = "css=input[value='Reply']"
  21. _reply_link = "css=a[href='#thread-reply']"
  22. _pagination_link = "css=ol.pagination"
  23. _next_page_link = "css=li.next"
  24. _prev_page_link = "css=li.prev"
  25. _locked_thread_format = "css=ol.threads li:nth-child(%d) > div > img[title='Locked']"
  26. _unlocked_thread_format = "css=ol.threads > li:nth-child(%d) > div:nth-child(2) > a"
  27. def __init__(self, testsetup):
  28. self.forums_cat_list_url = testsetup.base_url_ssl + '/en-US/forums'
  29. self.kb_articles_forum_url = testsetup.base_url_ssl + '/en-US/forums/knowledge-base-articles'
  30. super(ForumsPage, self).__init__(testsetup)
  31. def post_new_thread_first_cat(self, thread_title, thread_content):
  32. self.selenium.click(self._post_new_thread_link)
  33. self.selenium.wait_for_page_to_load(self.timeout)
  34. self.selenium.type(self._thread_title_box, thread_title)
  35. self.selenium.type(self._thread_content_box, thread_content)
  36. self.selenium.click(self._post_button)
  37. self.selenium.wait_for_page_to_load(self.timeout)
  38. if not (self.selenium.is_text_present(thread_title)):
  39. raise Exception("Posting new thread failed\r\n")
  40. def go_to_forums_cat_list_page(self):
  41. self.selenium.open(self.forums_cat_list_url)
  42. self.selenium.wait_for_page_to_load(self.timeout)
  43. self.is_the_current_page
  44. def post_reply(self, thread_url, reply_text):
  45. self.go_to_thread(thread_url)
  46. self.selenium.type(self._thread_content_box, reply_text)
  47. self.selenium.click(self._reply_button)
  48. self.selenium.wait_for_page_to_load(self.timeout)
  49. if not(self.selenium.is_text_present(reply_text)):
  50. raise Exception('Posting reply failed\r\n')
  51. def go_to_thread(self, url):
  52. self.selenium.open(url)
  53. self.selenium.wait_for_page_to_load(self.timeout)