@@ -73,6 +73,12 @@ def click_generate_draft_button(self):
7373 # Type a question in the text area
7474 self .page .locator (self .GENERATE_DRAFT ).click ()
7575 self .page .wait_for_timeout (15000 )
76+
77+ def click_browse_button (self ):
78+ # click on BROWSE
79+ self .page .wait_for_timeout (3000 )
80+ self .page .locator (self .BROWSE_BUTTON ).click ()
81+ self .page .wait_for_timeout (5000 )
7682
7783 def show_chat_history (self ):
7884 """Click to show chat history if the button is visible."""
@@ -120,13 +126,20 @@ def delete_chat_history(self):
120126 self .page .wait_for_timeout (2000 )
121127
122128 def validate_draft_button_enabled (self ):
129+ """
130+ Check if Generate Draft button is enabled.
131+ Returns True if enabled, False if disabled.
132+ """
123133 self .page .wait_for_timeout (5000 )
124134 generate_draft_button = self .page .locator (self .GENERATE_DRAFT )
125- with check :
126- if not generate_draft_button .is_enabled ():
127- logger .error ("❌ 'Generate Draft' button is disabled." )
128- else :
129- logger .info ("✅ 'Generate Draft' button is enabled." )
135+ is_enabled = generate_draft_button .is_enabled ()
136+
137+ if not is_enabled :
138+ logger .info ("✅ 'Generate Draft' button is disabled (as expected on launch)." )
139+ else :
140+ logger .info ("✅ 'Generate Draft' button is enabled." )
141+
142+ return is_enabled
130143
131144 def select_history_thread (self , thread_index = 0 ):
132145 """Select a history thread from the template history panel."""
@@ -157,29 +170,27 @@ def click_new_chat_button(self):
157170 logger .info ("New Chat button clicked successfully" )
158171
159172 def verify_saved_chat (self , expected_text : str ):
160- """Verify that the saved chat contains specific expected text."""
161-
162- # Locator for all chat messages (user + GPT)
163- chat_messages = self .page .locator (
164- '._chatMessageUserMessage_1dc7g_87, ._answerText_1qm4u_14'
165- )
166173
167- # Fail if there are no messages at all
174+ chat_messages_locator = '._chatMessageUserMessage_1dc7g_87, ._answerText_1qm4u_14'
175+
176+ # Wait for first message to load (up to 5 seconds)
177+ try :
178+ self .page .locator (chat_messages_locator ).first .wait_for (timeout = 5000 )
179+ except :
180+ assert False , "Chat messages did not load within timeout."
181+
182+ chat_messages = self .page .locator (chat_messages_locator )
183+
168184 assert chat_messages .count () > 0 , "No chat messages found — saved chat did not load."
169185
170- # Check if expected text exists in any message
171- found = False
172- count = chat_messages .count ()
173-
174- for i in range (count ):
175- message_text = chat_messages .nth (i ).inner_text ()
176- if expected_text in message_text :
177- found = True
178- break
186+ # Search messages for expected text
187+ found = any (
188+ expected_text in chat_messages .nth (i ).inner_text ()
189+ for i in range (chat_messages .count ())
190+ )
179191
180192 assert found , f"Expected text '{ expected_text } ' not found in saved chat."
181- logger .info (f"Verified saved chat contains expected text: { expected_text } " )
182-
193+
183194 def delete_thread_by_index (self , thread_index : int = 0 ):
184195 """
185196 Delete a session thread based on its index and verify it is removed.
0 commit comments