def assertUserCanBeDisabledAndThenEnabled(self, should_use_listbox, should_refresh_page): """Helper method for testing disabling and enabling a user. Args: should_use_listbox: If true, it will disable and enable a user from the user listbox. Otherwise, it will use the details dialog. should_refresh_page: If true, it will refresh the login page in between to check that the backend updates with the UI. """ landing_page = LandingPage(self.driver) test_user_item = landing_page.findTestUser( BaseTest.TEST_USER_AS_DICT['name']) # Set the container element to find the disable/enable button and text on. # Will be either the item within the listbox or the overall details dialog. container_element = landing_page.getContainerElementForItem( test_user_item, should_use_listbox) # Get the initial enable/disable text. initial_disabled_enabled_button_text = container_element.find_element( *LandingPage.USER_DISABLE_ENABLE_BUTTON).text # Click disable on that user. landing_page.clickDisableEnableOnUserElement(container_element) # Renavigate to the landing page to ensure the backend changed vs just a # UI update if specified. if should_refresh_page: self.driver.get(self.args.server_url + flask.url_for('landing')) test_user_item = landing_page.findTestUser( BaseTest.TEST_USER_AS_DICT['name']) # Set the container element to find the disable/enable button and text on. # Will be either the item within the listbox or the overall details dialog. container_element = landing_page.getContainerElementForItem( test_user_item, should_use_listbox) # Check the enable/disable text changed. changed_disabled_enabled_button_text = container_element.find_element( *LandingPage.USER_DISABLE_ENABLE_BUTTON).text self.assertNotEquals(initial_disabled_enabled_button_text, changed_disabled_enabled_button_text) # Flip back to enable. landing_page.clickDisableEnableOnUserElement(container_element) # Renavigate to the landing page to ensure the backend changed vs just a # UI update if specified. if should_refresh_page: self.driver.get(self.args.server_url + flask.url_for('landing')) test_user_item = landing_page.findTestUser( BaseTest.TEST_USER_AS_DICT['name']) # Set the container element to find the disable/enable button and text on. container_element = landing_page.getContainerElementForItem( test_user_item, should_use_listbox) # Check the enable/disable text changed back to the initial. final_disabled_enabled_button_text = container_element.find_element( *LandingPage.USER_DISABLE_ENABLE_BUTTON).text self.assertNotEquals(changed_disabled_enabled_button_text, final_disabled_enabled_button_text) self.assertEquals(initial_disabled_enabled_button_text, final_disabled_enabled_button_text)
def assertUserCanBeDisabledAndThenEnabled(self, should_use_listbox, should_refresh_page): """Helper method for testing disabling and enabling a user. Args: should_use_listbox: If true, it will disable and enable a user from the user listbox. Otherwise, it will use the details dialog. should_refresh_page: If true, it will refresh the login page in between to check that the backend updates with the UI. """ landing_page = LandingPage(self.driver) test_user_item = landing_page.findTestUser( BaseTest.TEST_USER_AS_DICT['name']) # Set the container element to find the disable/enable button and text on. # Will be either the item within the listbox or the overall details dialog. container_element = landing_page.getContainerElementForItem( test_user_item, should_use_listbox) # Get the initial enable/disable text. initial_disabled_enabled_button_text = container_element.find_element( *LandingPage.USER_DISABLE_ENABLE_BUTTON).text # Click disable on that user. landing_page.clickDisableEnableOnUserElement(container_element) # Renavigate to the landing page to ensure the backend changed vs just a # UI update if specified. if should_refresh_page: self.driver.get(self.args.server_url + flask.url_for('landing')) test_user_item = landing_page.findTestUser( BaseTest.TEST_USER_AS_DICT['name']) # Set the container element to find the disable/enable button and text on. # Will be either the item within the listbox or the overall details dialog. container_element = landing_page.getContainerElementForItem( test_user_item, should_use_listbox) # Check the enable/disable text changed. changed_disabled_enabled_button_text = container_element.find_element( *LandingPage.USER_DISABLE_ENABLE_BUTTON).text self.assertNotEquals(initial_disabled_enabled_button_text, changed_disabled_enabled_button_text) # Flip back to enable. landing_page.clickDisableEnableOnUserElement(container_element) # Renavigate to the landing page to ensure the backend changed vs just a # UI update if specified. if should_refresh_page: self.driver.get(self.args.server_url + flask.url_for('landing')) test_user_item = landing_page.findTestUser( BaseTest.TEST_USER_AS_DICT['name']) # Set the container element to find the disable/enable button and text on. container_element = landing_page.getContainerElementForItem( test_user_item, should_use_listbox) # Check the enable/disable text changed back to the initial. final_disabled_enabled_button_text = container_element.find_element( *LandingPage.USER_DISABLE_ENABLE_BUTTON).text self.assertNotEquals(changed_disabled_enabled_button_text, final_disabled_enabled_button_text) self.assertEquals(initial_disabled_enabled_button_text, final_disabled_enabled_button_text)