PageRenderTime 65ms CodeModel.GetById 38ms RepoModel.GetById 0ms app.codeStats 0ms

/pages/desktop/refine_search_page.py

https://github.com/AlinT/sumo-tests
Python | 65 lines | 49 code | 11 blank | 5 comment | 0 complexity | 363953a0082c2d2b9bad6a8bd576390b 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. from selenium.webdriver.common.by import By
  7. class RefineSearchPage(Base):
  8. """
  9. 'Advanced Search' page.
  10. """
  11. _page_title = 'Advanced Search | Mozilla Support'
  12. _page_url = '/en-US/search?a=2'
  13. _article_search_box = (By.ID, 'kb_q')
  14. _post_search_box = (By.ID, 'support_q')
  15. _post_tags_box = (By.ID, 'id_q_tags')
  16. _thread_search_box = (By.ID, 'discussion_q')
  17. _search_button_kb = (By.CSS_SELECTOR, 'input[name="w"][value="1"]+div.submit-search > input[type="submit"]')
  18. _search_button_support = (By.CSS_SELECTOR, '#support > div.submit-search > button')
  19. _search_button_disc = (By.CSS_SELECTOR, 'input[name="w"][value="4"]+div.submit-search > input[type="submit"]')
  20. _kb_cat_check_box = (By.CSS_SELECTOR, 'input#id_category_0')
  21. _kb_tab = (By.CSS_SELECTOR, 'div#search-tabs > ul > li:nth-child(1) > a')
  22. _support_questions_tab = (By.CSS_SELECTOR, 'div#search-tabs > ul > li:nth-child(2) > a')
  23. _forums_tab = (By.CSS_SELECTOR, 'div#search-tabs > ul > li:nth-child(3) > a')
  24. _asked_by_box = (By.ID, 'id_asked_by')
  25. _search_results_list = (By.CSS_SELECTOR, 'div.result.question')
  26. def click_support_questions_tab(self):
  27. self.selenium.find_element(*self._support_questions_tab).click()
  28. def type_in_asked_by_box(self, text):
  29. self.selenium.find_element(*self._asked_by_box).send_keys(text)
  30. def click_search_button_support(self):
  31. self.selenium.find_element(*self._search_button_support).click()
  32. def do_search_on_knowledge_base(self, search_query, search_page_obj):
  33. self.selenium.find_element(*self._kb_tab).click()
  34. self.selenium.find_element(*self.article_search_box).send_keys(search_query)
  35. self.selenium.find_element(*self._search_button_kb).click()
  36. search_page_obj.is_the_current_page
  37. def do_search_on_support_questions(self, search_query, search_page_obj):
  38. self.selenium.find_element(*self._support_questions_tab).click()
  39. self.selenium.find_element(*self.post_search_box).send_keys(search_query)
  40. self.selenium.find_element(*self._search_button_support).click()
  41. search_page_obj.is_the_current_page
  42. def do_search_tags_on_support_questions(self, search_query, search_page_obj):
  43. self.selenium.find_element(*self._support_questions_tab).click()
  44. self.selenium.find_element(*self._post_tags_box).send_keys(search_query)
  45. self.selenium.find_element(*self._search_button_support).click()
  46. search_page_obj.is_the_current_page
  47. def do_search_on_discussion_forums(self, search_query, search_page_obj):
  48. self.selenium.find_element(*self._forums_tab).click()
  49. self.selenium.find_element(*self._thread_search_box).send_keys(search_query)
  50. self.selenium.find_element(*self._search_button_disc).click()
  51. search_page_obj.is_the_current_page
  52. @property
  53. def search_result_count(self):
  54. return len(self.selenium.find_elements(*self._search_results_list))