@@ -536,24 +536,26 @@ def toggle_visibility(n_clicks):
536536 assert text_color is not None and len (text_color ) > 0
537537
538538 # Test toggle functionality
539+ # Wait for content to be displayed initially
540+ dash_duo .wait_for_element_by_id ('toggle-content' )
539541 toggle_content = dash_duo .find_element ('#toggle-content' )
542+ # Use wait_for_style_to_equal to ensure the element is displayed
543+ dash_duo .wait_for_style_to_equal ('#toggle-content' , 'display' , 'block' )
540544 assert toggle_content .is_displayed ()
541545
542546 # Click toggle button to hide content
543547 dash_duo .find_element ('#toggle-button' ).click ()
544- dash_duo .wait_for_element_by_id ('toggle-content' )
545- # Wait a moment for the transition
546- dash_duo .driver .implicitly_wait (1 )
548+ # Wait for the element to be hidden
549+ dash_duo .wait_for_style_to_equal ('#toggle-content' , 'display' , 'none' )
547550 # Check that content is hidden
548551 # We need to re-find the element after the DOM update
549552 toggle_content = dash_duo .find_element ('#toggle-content' )
550553 assert not toggle_content .is_displayed ()
551554
552555 # Click toggle button again to show content
553556 dash_duo .find_element ('#toggle-button' ).click ()
554- dash_duo .wait_for_element_by_id ('toggle-content' )
555- # Wait a moment for the transition
556- dash_duo .driver .implicitly_wait (1 )
557+ # Wait for the element to be displayed again
558+ dash_duo .wait_for_style_to_equal ('#toggle-content' , 'display' , 'block' )
557559 # Check that content is displayed again
558560 # We need to re-find the element after the DOM update
559561 toggle_content = dash_duo .find_element ('#toggle-content' )
0 commit comments