<s> from selenium . webdriver . common import by <EOL> from openstack_dashboard . test . integration_tests . regions import baseregion <EOL> class CannotClickMenuItemException ( Exception ) : <EOL> pass <EOL> class NavigationAccordionRegion ( baseregion . BaseRegion ) : <EOL> """<STR_LIT>""" <EOL> _project_access_security_locator = ( <EOL> by . By . CSS_SELECTOR , '<STR_LIT>' ) <EOL> _settings_change_password_locator = ( <EOL> by . By . CSS_SELECTOR , '<STR_LIT>' ) <EOL> _project_bar_locator = ( by . By . XPATH , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> MAX_MENU_ITEM_CLICK_TRIES = <NUM_LIT:100> <EOL> @ property <EOL> def project_bar ( self ) : <EOL> return self . _get_element ( * self . _project_bar_locator ) <EOL> _first_level_item_selected_locator = ( by . By . CSS_SELECTOR , '<STR_LIT>' ) <EOL> _second_level_item_selected_locator = ( by . By . CSS_SELECTOR , '<STR_LIT>' ) <EOL> _first_level_item_xpath_template = '<STR_LIT>' <EOL> _second_level_item_xpath_template = '<STR_LIT>' <EOL> _third_level_item_xpath_template = '<STR_LIT>' <EOL> def _get_first_level_item_locator ( self , text ) : <EOL> return ( by . By . XPATH , <EOL> self . _first_level_item_xpath_template % text ) <EOL> def _get_second_level_item_locator ( self , text ) : <EOL> return ( by . By . XPATH , <EOL> self . _second_level_item_xpath_template % text ) <EOL> def _get_third_level_item_locator ( self , text ) : <EOL> return ( by . By . XPATH , <EOL> self . _third_level_item_xpath_template % text ) <EOL> def get_first_level_selected_item ( self ) : <EOL> if self . _is_element_present ( * self . _first_level_item_selected_locator ) : <EOL> return self . _get_element ( * self . _first_level_item_selected_locator ) <EOL> else : <EOL> return None <EOL> def get_second_level_selected_item ( self ) : <EOL> if self . _is_element_present ( * self . _second_level_item_selected_locator ) : <EOL> return self . _get_element ( * self . _second_level_item_selected_locator ) <EOL> else : <EOL> return None <EOL> @ property <EOL> def access_security ( self ) : <EOL> return self . _get_element ( * self . _project_access_security_locator ) <EOL> @ property <EOL> def change_password ( self ) : <EOL> return self . _get_element ( * self . _settings_change_password_locator ) <EOL> def _click_menu_item ( self , text , loc_craft_func , get_selected_func = None ) : <EOL> """<STR_LIT>""" <EOL> if not get_selected_func : <EOL> self . _click_item ( text , loc_craft_func ) <EOL> else : <EOL> for _ in xrange ( self . MAX_MENU_ITEM_CLICK_TRIES ) : <EOL> selected_item = get_selected_func ( ) <EOL> if selected_item and text == selected_item . text : <EOL> break <EOL> if selected_item : <EOL> selected_item . click ( ) <EOL> self . _click_item ( text , loc_craft_func ) <EOL> else : <EOL> raise CannotClickMenuItemException ( ) <EOL> def _click_item ( self , text , loc_craft_func ) : <EOL> """<STR_LIT>""" <EOL> item_locator = loc_craft_func ( text ) <EOL> item = self . _get_element ( * item_locator ) <EOL> item . click ( ) <EOL> def click_on_menu_items ( self , first_level = None , <EOL> second_level = None , <EOL> third_level = None ) : <EOL> if first_level : <EOL> self . _click_menu_item ( first_level , <EOL> self . _get_first_level_item_locator , <EOL> self . get_first_level_selected_item ) <EOL> if second_level : <EOL> self . _click_menu_item ( second_level , <EOL> self . _get_second_level_item_locator , <EOL> self . get_second_level_selected_item ) <EOL> if third_level : <EOL> self . _click_menu_item ( third_level , <EOL> self . _get_third_level_item_locator ) <EOL> class DropDownMenuRegion ( baseregion . BaseRegion ) : <EOL> """<STR_LIT>""" <EOL> _menu_items_locator = ( by . By . CSS_SELECTOR , '<STR_LIT>' ) <EOL> _menu_first_child_locator = ( by . By . CSS_SELECTOR , '<STR_LIT:*>' ) <EOL> @ property <EOL> def menu_items ( self ) : <EOL> self . open ( ) <EOL> menu_items = self . _get_elements ( * self . _menu_items_locator ) <EOL> return menu_items <EOL> def is_open ( self ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" in self . src_elem . get_attribute ( '<STR_LIT:class>' ) <EOL> def open ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . is_open ( ) is False : <EOL> self . _get_element ( * self . _menu_first_child_locator ) . click ( ) <EOL> class UserDropDownMenuRegion ( DropDownMenuRegion ) : <EOL> """<STR_LIT>""" <EOL> _settings_link_locator = ( by . By . CSS_SELECTOR , <EOL> '<STR_LIT>' ) <EOL> _help_link_locator = ( by . By . CSS_SELECTOR , <EOL> '<STR_LIT>' ) <EOL> _logout_link_locator = ( by . By . CSS_SELECTOR , <EOL> '<STR_LIT>' ) <EOL> @ property <EOL> def settings_link ( self ) : <EOL> return self . _get_element ( * self . _settings_link_locator ) <EOL> @ property <EOL> def help_link ( self ) : <EOL> return self . _get_element ( * self . _help_link_locator ) <EOL> @ property <EOL> def logout_link ( self ) : <EOL> return self . _get_element ( * self . _logout_link_locator ) <EOL> def click_on_settings ( self ) : <EOL> self . open ( ) <EOL> self . settings_link . click ( ) <EOL> def click_on_help ( self ) : <EOL> self . open ( ) <EOL> self . help_link . click ( ) <EOL> def click_on_logout ( self ) : <EOL> self . open ( ) <EOL> self . logout_link . click ( ) </s>
