Last active
August 29, 2015 14:01
-
-
Save cch5ng/7a0b714c01da85f274a6 to your computer and use it in GitHub Desktop.
Working /pages/about_page.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # This Source Code Form is subject to the terms of the Mozilla Public | |
| # License, v. 2.0. If a copy of the MPL was not distributed with this | |
| # file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| from selenium.webdriver.common.by import By | |
| from selenium.webdriver.common.action_chains import ActionChains | |
| from selenium.webdriver.support.ui import WebDriverWait | |
| from page import Page | |
| class AboutPage(Page): | |
| _page_title = 'About | Firefox Affiliates' | |
| _page_url = '/about' | |
| _page_header_locator = (By.CSS_SELECTOR, 'h1.page-title') | |
| _section_header_locator = (By.CSS_SELECTOR, 'h2.section-title') | |
| _faq_category_locator = (By.TAG_NAME, 'h3') | |
| _faq_question_locator = (By.CSS_SELECTOR, 'dl.faq dt') | |
| _faq_answer_locator = (By.CSS_SELECTOR, 'dl.faq dd p') | |
| _logout_locator = (By.CSS_SELECTOR, 'ul#nav-main-menu li:nth-of-type(3) ul#nav-user-submenu li:nth-of-type(3) a.browserid-logout') | |
| _mozilla_logo_link_locator = (By.CSS_SELECTOR, 'h2.site-logo') | |
| _newsletter_form_locator = (By.CSS_SELECTOR, '#newsletter-form') | |
| _footer_locator = (By.CSS_SELECTOR, '#footer') | |
| #Not LoggedIn | |
| _login_browser_id_locator = (By.CSS_SELECTOR, 'a.persona-button') | |
| @property | |
| def questions_count(self): | |
| return len(self.selenium.find_elements(*self._faq_question_locator)) | |
| @property | |
| def questions_text(self): | |
| return self.selenium.find_element(*self._faq_question_locator).text | |
| @property | |
| def answer(self, lookup): | |
| return self.selenium.find_element(By.CSS_SELECTOR, | |
| 'dl.faq_content dd:nth-of-type(%s) p' % lookup).text | |
| @property | |
| def header(self): | |
| return self.selenium.find_element(*self._page_header_locator).text.replace('\n', ' ') | |
| @property | |
| def section_header(self): | |
| return self.selenium.find_element(*self._section_header_locator).text | |
| @property | |
| def is_category_present(self): | |
| return self.is_element_present(*self._faq_locator) | |
| @property | |
| def is_question_present(self): | |
| return self.is_element_present(*self._faq_question_locator) | |
| @property | |
| def is_answer_present(self): | |
| return self.is_element_present(*self._faq_answer_locator) | |
| @property | |
| def is_mozilla_logo_visible(self): | |
| return self.is_element_visible(*self._mozilla_logo_link_locator) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment