fe04af039f
Since most probable cause of dropdowns not opening intermittently is Bootstrap initialization code not having enough time to complete before test tries to open dropdown, make test wait a specified timeout before clicking it (by means of setting a CSS class after that timeout, which test in turn waits before clicking the dropdown). Closes-Bug: #1594926 Change-Id: I32625caa4433f4af0de72c94b61e85ab4e16b1f9
62 lines
2.3 KiB
Python
62 lines
2.3 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.regions import baseregion
|
|
from openstack_dashboard.test.integration_tests.regions import menus
|
|
|
|
|
|
class TopBarRegion(baseregion.BaseRegion):
|
|
_user_dropdown_menu_locator = (by.By.CSS_SELECTOR,
|
|
'.nav.navbar-nav.navbar-right')
|
|
_openstack_brand_locator = (by.By.CSS_SELECTOR, 'a[href*="/home/"]')
|
|
|
|
_user_dropdown_project_locator = (
|
|
by.By.CSS_SELECTOR, '.navbar-collapse > ul.navbar-nav:first-child')
|
|
_header_locator = (by.By.CSS_SELECTOR, 'nav.navbar-fixed-top')
|
|
|
|
MATERIAL_THEME_CLASS = 'material-header'
|
|
|
|
@property
|
|
def user(self):
|
|
return self._get_element(*self._user_dropdown_menu_locator)
|
|
|
|
@property
|
|
def brand(self):
|
|
return self._get_element(*self._openstack_brand_locator)
|
|
|
|
@property
|
|
def header(self):
|
|
return self._get_element(*self._header_locator)
|
|
|
|
@property
|
|
def is_material_theme_enabled(self):
|
|
classes = self.header.get_attribute('class').strip().split()
|
|
return self.MATERIAL_THEME_CLASS in classes
|
|
|
|
@property
|
|
def user_dropdown_menu(self):
|
|
src_elem = self._get_element(*self._user_dropdown_menu_locator)
|
|
return menus.UserDropDownMenuRegion(self.driver,
|
|
self.conf, src_elem)
|
|
|
|
@property
|
|
def is_logged_in(self):
|
|
return self._is_element_visible(*self._user_dropdown_menu_locator)
|
|
|
|
@property
|
|
def user_dropdown_project(self):
|
|
src_elem = self._get_element(*self._user_dropdown_project_locator)
|
|
return menus.ProjectDropDownRegion(self.driver,
|
|
self.conf, src_elem)
|