Skip to content

Commit ea0a96d

Browse files
included more test cases
1 parent 5c83ffc commit ea0a96d

3 files changed

Lines changed: 3673 additions & 2034 deletions

File tree

tests/e2e-test/pages/draftPage.py

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,4 +541,83 @@ def test_character_limit_restriction(self, section_index=0):
541541
logger.error(f"❌ Failed to verify character count label: {e}")
542542
raise
543543

544-
return actual_length
544+
return actual_length
545+
546+
def enter_document_title(self, title):
547+
"""
548+
Enter a title in the document title text box on the Draft page
549+
550+
Args:
551+
title: The title to enter in the document title field
552+
"""
553+
try:
554+
logger.info(f"🔹 Entering document title: '{title}'")
555+
556+
# Primary locator: by placeholder text
557+
title_input = self.page.locator("input[placeholder='Enter title here']")
558+
559+
# Check if input field is visible
560+
if not title_input.is_visible(timeout=5000):
561+
# Try alternative locator: by class name
562+
logger.warning("⚠️ Title input not found by placeholder, trying by class")
563+
title_input = self.page.locator("input.ms-TextField-field")
564+
565+
# Wait for the input to be editable
566+
title_input.wait_for(state="visible", timeout=5000)
567+
568+
# Scroll to the input field if needed
569+
title_input.scroll_into_view_if_needed()
570+
self.page.wait_for_timeout(500)
571+
572+
# Clear any existing title
573+
title_input.clear()
574+
self.page.wait_for_timeout(300)
575+
576+
# Enter new title
577+
title_input.fill(title)
578+
self.page.wait_for_timeout(500)
579+
580+
# Verify the title was entered correctly
581+
entered_value = title_input.input_value()
582+
if entered_value == title:
583+
logger.info(f"✅ Successfully entered document title: '{title}'")
584+
else:
585+
logger.warning(f"⚠️ Title mismatch - Expected: '{title}', Got: '{entered_value}'")
586+
587+
except Exception as e:
588+
logger.error(f"❌ Failed to enter document title: {e}")
589+
# Take screenshot for debugging
590+
try:
591+
screenshot_path = "screenshots/title_input_error.png"
592+
os.makedirs("screenshots", exist_ok=True)
593+
self.page.screenshot(path=screenshot_path)
594+
logger.error(f"📸 Screenshot saved: {screenshot_path}")
595+
except:
596+
pass
597+
raise
598+
599+
def click_export_document_button(self):
600+
"""
601+
Click the 'Export Document' button at the bottom of the Draft page
602+
"""
603+
try:
604+
# Locate the Export Document button using the class and text
605+
# Button structure: <button class="ms-Button ms-Button--commandBar _exportDocumentIcon_1x53n_11 root-239" aria-label="export document">
606+
export_button = self.page.locator("button[aria-label='export document']")
607+
608+
if not export_button.is_visible(timeout=5000):
609+
# Try alternative locator by text
610+
export_button = self.page.locator("button:has-text('Export Document')")
611+
612+
# Scroll to button if needed
613+
export_button.scroll_into_view_if_needed()
614+
self.page.wait_for_timeout(500)
615+
616+
# Click the button
617+
export_button.click()
618+
619+
logger.info("✅ Clicked 'Export Document' button")
620+
621+
except Exception as e:
622+
logger.error(f"❌ Failed to click Export Document button: {e}")
623+
raise

tests/e2e-test/pages/generatePage.py

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)