<s> from selenium . webdriver . common import by <EOL> from selenium . webdriver . common import keys <EOL> from openstack_dashboard . test . integration_tests . pages . admin . system import overviewpage as system_overviewpage <EOL> from openstack_dashboard . test . integration_tests . pages import pageobject <EOL> from openstack_dashboard . test . integration_tests . pages . project . compute import overviewpage as compute_overviewpage <EOL> class LoginPage ( pageobject . PageObject ) : <EOL> _login_username_field_locator = ( by . By . ID , '<STR_LIT>' ) <EOL> _login_password_field_locator = ( by . By . ID , '<STR_LIT>' ) <EOL> _login_submit_button_locator = ( by . By . CSS_SELECTOR , <EOL> '<STR_LIT>' ) <EOL> _login_logout_reason_locator = ( by . By . ID , '<STR_LIT>' ) <EOL> def __init__ ( self , driver , conf ) : <EOL> super ( LoginPage , self ) . __init__ ( driver , conf ) <EOL> self . _page_title = "<STR_LIT>" <EOL> def is_login_page ( self ) : <EOL> return ( self . is_the_current_page ( ) and <EOL> self . _is_element_visible ( * self . _login_submit_button_locator ) ) <EOL> @ property <EOL> def username ( self ) : <EOL> return self . _get_element ( * self . _login_username_field_locator ) <EOL> @ property <EOL> def password ( self ) : <EOL> return self . _get_element ( * self . _login_password_field_locator ) <EOL> @ property <EOL> def login_button ( self ) : <EOL> return self . _get_element ( * self . _login_submit_button_locator ) <EOL> def _click_on_login_button ( self ) : <EOL> self . login_button . click ( ) <EOL> def _press_enter_on_login_button ( self ) : <EOL> self . login_button . send_keys ( keys . Keys . RETURN ) <EOL> def is_logout_reason_displayed ( self ) : <EOL> return self . _get_element ( * self . _login_logout_reason_locator ) <EOL> def login ( self , user = None , password = None ) : <EOL> return self . login_with_mouse_click ( user , password ) <EOL> def login_with_mouse_click ( self , user , password ) : <EOL> return self . _do_login ( user , password , self . _click_on_login_button ) <EOL> def login_with_enter_key ( self , user , password ) : <EOL> return self . _do_login ( user , password , <EOL> self . _press_enter_on_login_button ) <EOL> def _do_login ( self , user , password , login_method ) : <EOL> if user == self . conf . identity . admin_username : <EOL> if password is None : <EOL> password = self . conf . identity . admin_password <EOL> return self . login_as_admin ( password , login_method ) <EOL> else : <EOL> if password is None : <EOL> password = self . conf . identity . password <EOL> if user is None : <EOL> user = self . conf . identity . username <EOL> return self . login_as_user ( user , password , login_method ) <EOL> def login_as_admin ( self , password , login_method ) : <EOL> self . username . send_keys ( self . conf . identity . admin_username ) <EOL> self . password . send_keys ( password ) <EOL> login_method ( ) <EOL> return system_overviewpage . OverviewPage ( self . driver , self . conf ) <EOL> def login_as_user ( self , user , password , login_method ) : <EOL> self . username . send_keys ( user ) <EOL> self . password . send_keys ( password ) <EOL> login_method ( ) <EOL> return compute_overviewpage . OverviewPage ( self . driver , self . conf ) </s>
