Source code for openstack_dashboard.test.integration_tests.pages.basepage

#    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.pages import pageobject


[docs]class BasePage(pageobject.PageObject): """Base class for all dashboard page objects.""" @property
[docs] def topbar(self): return BasePage.TopBarRegion(self.driver, self.conf)
@property
[docs] def is_logged_in(self): return self.topbar.is_logged_in
[docs] def go_to_login_page(self): self.driver.get(self.login_url)
[docs] def go_to_home_page(self): self.topbar.brand.click()
[docs] def log_out(self): self.topbar.logout_link.click() return self.go_to_login_page()
[docs] class TopBarRegion(pageobject.PageObject): _user_indicator_locator = (by.By.CSS_SELECTOR, '#profile_editor_switcher > ' 'a.dropdown-toggle > div') _user_dropdown_menu_locator = (by.By.CSS_SELECTOR, '#profile_editor_switcher >' ' a.dropdown-toggle') _settings_link_locator = (by.By.CSS_SELECTOR, 'a[href*="/settings/"]') _help_link_locator = (by.By.CSS_SELECTOR, 'ul#editor_list li:nth-of-type(3) > a') _logout_link_locator = (by.By.CSS_SELECTOR, 'a[href*="/auth/logout/"]') _openstack_brand_locator = (by.By.CSS_SELECTOR, 'a[href*="/home/"]') @property
[docs] def user(self): return self.get_element(*self._user_indicator_locator)
@property
[docs] def brand(self): return self.get_element(*self._openstack_brand_locator)
@property @property
[docs] def user_dropdown_menu(self): return self.get_element(*self._user_dropdown_menu_locator)
@property @property @property
[docs] def is_logout_visible(self): return self.is_element_visible(*self._logout_link_locator)
@property
[docs] def is_logged_in(self): return self.is_element_visible(*self._user_indicator_locator)