Files
horizon/openstack_dashboard/test/integration_tests/pages/basepage.py
Tomas Novacik 6107972e53 Add regions module to integration tests
Regions module should contains basic functionality that should be
shared among multiple page objects: common tables, forms,
notifications etc.. Basically every piece of code that can be reused by
multiple classes in a form of a new object should be placed in here.

* I would suggest that already created regions should be moved into this
  module.

* I would consider region everything that can be reused by at least
  two page objects and aim for maximal code reusability in the future.

* Every new region should inherit from class BaseRegion located in
  baseregion.py.

Partially implements blueprint: selenium-integration-testing

Change-Id: Ib8c20d8833e0830c85030633091663d33de6e3ab
2014-11-21 18:11:18 +01:00

87 lines
2.9 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from selenium.webdriver.common import by
from openstack_dashboard.test.integration_tests import basewebobject
from openstack_dashboard.test.integration_tests.pages import pageobject
from openstack_dashboard.test.integration_tests.regions import bars
from openstack_dashboard.test.integration_tests.regions import messages
class BasePage(pageobject.PageObject):
"""Base class for all dashboard page objects."""
_heading_locator = (by.By.CSS_SELECTOR, 'div.page-header > h2')
_error_msg_locator = (by.By.CSS_SELECTOR, 'div.alert-danger.alert')
@property
def heading(self):
return self._get_element(*self._heading_locator)
@property
def topbar(self):
return bars.TopBarRegion(self.driver, self.conf)
@property
def is_logged_in(self):
return self.topbar.is_logged_in
@property
def navaccordion(self):
return BasePage.NavigationAccordionRegion(self.driver, self.conf)
def error_message(self):
src_elem = self._get_element(*self._error_msg_locator)
return messages.ErrorMessageRegion(self.driver, self.conf, src_elem)
def is_error_message_present(self):
return self._is_element_present(*self._error_msg_locator)
def go_to_login_page(self):
self.driver.get(self.login_url)
def go_to_home_page(self):
self.topbar.brand.click()
def log_out(self):
self.topbar.user_dropdown_menu.click()
self.topbar.logout_link.click()
return self.go_to_login_page()
def go_to_help_page(self):
self.topbar.user_dropdown_menu.click()
self.topbar.help_link.click()
class NavigationAccordionRegion(basewebobject.BaseWebObject):
# TODO(sunlim): change Xpath to CSS
_project_bar_locator = (
by.By.XPATH,
".//*[@id='main_content']//div[contains(text(),'Project')]")
_project_access_security_locator = (
by.By.CSS_SELECTOR, 'a[href*="/project/access_and_security/"]')
@property
def project_bar(self):
return self._get_element(*self._project_bar_locator)
def _click_on_project_bar(self):
self.project_bar.click()
@property
def access_security(self):
return self._get_element(*self._project_access_security_locator)
def _click_on_access_security(self):
self.access_security.click()