Merge "Add project-dropdown"

This commit is contained in:
Jenkins 2015-04-16 01:00:54 +00:00 committed by Gerrit Code Review
commit 3141600bc5
3 changed files with 36 additions and 4 deletions

View File

@ -74,6 +74,9 @@ class BasePage(pageobject.PageObject):
# it will raise the NoSuchElementException exception.
pass
def change_project(self, name):
self.topbar.user_dropdown_project.click_on_project(name)
class BaseNavigationPage(BasePage, navigation.Navigation):
pass

View File

@ -20,6 +20,9 @@ class TopBarRegion(baseregion.BaseRegion):
_user_dropdown_menu_locator = (by.By.ID, 'profile_editor_switcher')
_openstack_brand_locator = (by.By.CSS_SELECTOR, 'a[href*="/home/"]')
_user_dropdown_project_locator = (by.By.CSS_SELECTOR,
'div.dropdown.context-selection')
@property
def user(self):
return self._get_element(*self._user_dropdown_menu_locator)
@ -37,3 +40,9 @@ class TopBarRegion(baseregion.BaseRegion):
@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)

View File

@ -9,6 +9,7 @@
# 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.common import exceptions
from selenium.webdriver.common import by
from openstack_dashboard.test.integration_tests.regions import baseregion
@ -129,8 +130,10 @@ class NavigationAccordionRegion(baseregion.BaseRegion):
class DropDownMenuRegion(baseregion.BaseRegion):
"""Drop down menu region."""
_menu_items_locator = (by.By.CSS_SELECTOR, 'ul.dropdown-menu > li > *')
_menu_first_child_locator = (by.By.CSS_SELECTOR, '*')
_menu_items_locator = (by.By.CSS_SELECTOR,
'ul.dropdown-menu > li > *')
_menu_first_child_locator = (by.By.CSS_SELECTOR,
'a[data-toggle="dropdown"]')
@property
def menu_items(self):
@ -152,6 +155,7 @@ class UserDropDownMenuRegion(DropDownMenuRegion):
"""Drop down menu located in the right side of the topbar,
contains links to settings and help.
"""
_menu_first_child_locator = (by.By.CSS_SELECTOR, '*')
_settings_link_locator = (by.By.CSS_SELECTOR,
'a[href*="/settings/"]')
_help_link_locator = (by.By.CSS_SELECTOR,
@ -186,8 +190,24 @@ class UserDropDownMenuRegion(DropDownMenuRegion):
class TabbedMenuRegion(baseregion.BaseRegion):
_tab_locator = (by.By.CSS_SELECTOR, 'li')
_default_src_locator = (by.By.CSS_SELECTOR, 'ul.nav-tabs')
_tab_locator = (by.By.CSS_SELECTOR, 'a')
_default_src_locator = (by.By.CSS_SELECTOR, 'ul.nav.nav-tabs')
def switch_to(self, index=0):
self._get_elements(*self._tab_locator)[index].click()
class ProjectDropDownRegion(DropDownMenuRegion):
_menu_first_child_locator = (by.By.CSS_SELECTOR, '*')
_menu_items_locator = (by.By.CSS_SELECTOR,
'div.context-lists a')
def click_on_project(self, name):
for item in self.menu_items:
if item.text == name:
item.click()
break
else:
raise exceptions.NoSuchElementException(
"Not found element with text: %s" % name)