@@ -802,19 +802,21 @@ def test_theme_toggle(self):
802802 self .assertEqual (toolbar .get_attribute ("data-theme" ), "auto" )
803803
804804 # The theme toggle button is shown on the toolbar
805- self .assertIn ('<a id="djToggleThemeButton' , toolbar .text )
805+ toggle_button = self .selenium .find_element (By .ID , "djToggleThemeButton" )
806+ self .assertTrue (toggle_button .is_displayed ())
806807
807808 # The theme changes when user clicks the button
808- self . selenium . find_element ( By . ID , "djDebugToolbar" ) .click ()
809+ toggle_button .click ()
809810 self .assertEqual (toolbar .get_attribute ("data-theme" ), "light" )
810- self . selenium . find_element ( By . ID , "djDebugToolbar" ) .click ()
811+ toggle_button .click ()
811812 self .assertEqual (toolbar .get_attribute ("data-theme" ), "dark" )
813+ toggle_button .click ()
814+ self .assertEqual (toolbar .get_attribute ("data-theme" ), "auto" )
815+ # Switch back to light.
816+ toggle_button .click ()
817+ self .assertEqual (toolbar .get_attribute ("data-theme" ), "light" )
812818
813819 # Enter the page again to check that user settings is saved
814820 self .get ("/regular/basic/" )
815821 toolbar = self .selenium .find_element (By .ID , "djDebug" )
816- self .assertEqual (toolbar .get_attribute ("data-theme" ), "dark" )
817-
818- # Set the default again and check that dark changes to auto
819- self .selenium .find_element (By .ID , "djDebugToolbar" ).click ()
820- self .assertEqual (toolbar .get_attribute ("data-theme" ), "auto" )
822+ self .assertEqual (toolbar .get_attribute ("data-theme" ), "light" )
0 commit comments