@@ -14,7 +14,7 @@ class HomePage(BasePage):
1414 SEND_BUTTON = "//button[@title='Send Question']"
1515 SHOW_CHAT_HISTORY_BUTTON = "//button[normalize-space()='Show Chat History']"
1616 HIDE_CHAT_HISTORY_BUTTON = "//button[normalize-space()='Hide Chat History']"
17- CHAT_HISTORY_NAME = "//div[contains(@class, 'ChatHistoryListItemCell_chatTitle ')]"
17+ CHAT_HISTORY_NAME = "//div[contains(@class, 'chatTitle ')]"
1818 CLEAR_CHAT_HISTORY_MENU = "//button[@id='moreButton']"
1919 CLEAR_CHAT_HISTORY = "//button[@role='menuitem']"
2020 REFERENCE_LINKS_IN_RESPONSE = "//span[@role='button' and contains(@class, 'citationContainer')]"
@@ -85,13 +85,36 @@ def click_send_button(self):
8585
8686
8787 def show_chat_history (self ):
88+ # Click "Show Chat History" and wait for the panel + chat title items to render.
89+ # The /history/list API call can be slow on first open after a fresh conversation,
90+ # so we retry the click once and use a generous timeout before failing.
8891 self .page .locator (self .SHOW_CHAT_HISTORY_BUTTON ).click ()
8992 self .page .wait_for_load_state ('networkidle' )
90- self .page .wait_for_timeout (2000 )
93+ self .page .wait_for_timeout (3000 )
94+
95+ chat_title_locator = self .page .locator (self .CHAT_HISTORY_NAME ).first
9196 try :
92- expect (self .page .locator (self .CHAT_HISTORY_NAME )).to_be_visible (timeout = 9000 )
93- except AssertionError :
94- raise AssertionError ("Chat history name was not visible on the page within the expected time." )
97+ expect (chat_title_locator ).to_be_visible (timeout = 30000 )
98+ except Exception as first_err :
99+ # Retry once: close and reopen the panel in case the list didn't populate.
100+ logger .warning ("Chat history items not visible on first attempt, retrying..." )
101+ try :
102+ # Best-effort close: ignore any errors here so retry can still proceed.
103+ try :
104+ if self .page .locator (self .HIDE_CHAT_HISTORY_BUTTON ).is_visible ():
105+ self .page .locator (self .HIDE_CHAT_HISTORY_BUTTON ).click ()
106+ self .page .wait_for_timeout (2000 )
107+ except Exception as close_err :
108+ logger .warning (f"Best-effort close of chat history panel failed: { close_err } " )
109+
110+ self .page .locator (self .SHOW_CHAT_HISTORY_BUTTON ).click ()
111+ self .page .wait_for_load_state ('networkidle' )
112+ self .page .wait_for_timeout (3000 )
113+ expect (chat_title_locator ).to_be_visible (timeout = 30000 )
114+ except Exception as retry_err :
115+ raise AssertionError (
116+ "Chat history name was not visible on the page within the expected time."
117+ ) from retry_err
95118
96119 def delete_chat_history (self ):
97120 self .page .locator (self .SHOW_CHAT_HISTORY_BUTTON ).click ()
0 commit comments