moztrap-tests/pages/base_page.py

57 строки
2.0 KiB
Python
Исходник Обычный вид История

2011-09-20 02:31:46 +04:00
#!/usr/bin/env python
#
2012-02-20 19:10:25 +04:00
# 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/.
2011-09-20 02:31:46 +04:00
2012-04-30 18:01:27 +04:00
from selenium.webdriver.common.by import By
from pages.page import Page
2011-09-20 02:31:46 +04:00
2012-03-30 23:40:49 +04:00
class MozTrapBasePage(Page):
2011-09-20 03:15:10 +04:00
2012-04-30 18:01:27 +04:00
@property
def header(self):
return self.Header(self.testsetup)
2012-04-30 18:01:27 +04:00
class Header(Page):
2012-05-01 18:06:13 +04:00
_run_tests_locator = (By.CSS_SELECTOR, 'li.runtests-nav > a')
_manage_locator = (By.CSS_SELECTOR, 'li.manage-nav > a')
_user_name_locator = (By.CSS_SELECTOR, '#accountnav .account-welcome .fn')
_logout_locator = (By.CSS_SELECTOR, '#logoutform > button')
_signin_locator = (By.CSS_SELECTOR, '.signin')
2012-05-01 18:06:13 +04:00
_drilldown_locator = (By.CSS_SELECTOR, 'nav.drilldown > h2')
@property
def is_user_logged_in(self):
return self.is_element_visible(*self._logout_locator)
@property
def username_text(self):
return self.selenium.find_element(*self._user_name_locator).text
2012-05-01 18:06:13 +04:00
def click_logout(self):
self.selenium.find_element(*self._logout_locator).click()
def click_run_tests(self):
self.selenium.find_element(*self._run_tests_locator).click()
from pages.run_tests_page import MozTrapRunTestsPage
return MozTrapRunTestsPage(self.testsetup)
def click_manage_locator(self):
self.selenium.find_element(*self._manage_locator).click()
from pages.manage_runs_page import MozTrapManageRunsPage
return MozTrapManageRunsPage(self.testsetup)
def toggle_drilldown(self):
self.selenium.find_element(*self._drilldown_locator).click()
def click_login(self, user='default'):
self.find_element(*self._signin_locator).click()
from pages.login_page import MozTrapLoginPage
MozTrapLoginPage(self.testsetup).login(user)