@@ -11,9 +11,7 @@ class DkmPage(BasePage):
1111 NEWTOPIC = "//button[normalize-space()='New Topic']"
1212 Suggested_follow_up_questions = "body > div:nth-child(3) > div:nth-child(1) > main:nth-child(2) > div:nth-child(1) > div:nth-child(4) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > div:nth-child(6) > div:nth-child(3) > button:nth-child(2)"
1313 SCROLL_DOWN = "//div[10]//div[2]//div[2]//i[1]//img[1]"
14- ASK_QUESTION = (
15- "//textarea[@placeholder='Ask a question or request (ctrl + enter to submit)']"
16- )
14+ ASK_QUESTION = "(//textarea[@placeholder='Ask a question or request (ctrl + enter to submit)'])[1]"
1715 SEARCH_BOX = "//input[@type='search']"
1816 HOUSING_2022 = "//body[1]/div[2]/div[1]/main[1]/div[1]/div[2]/div[4]/div[1]/div[1]/div[2]/div[2]/div[2]/span[1]"
1917 HOUSING_2023 = "//body[1]/div[2]/div[1]/main[1]/div[1]/div[2]/div[4]/div[1]/div[1]/div[1]/div[2]/div[2]/span[1]"
@@ -25,11 +23,16 @@ class DkmPage(BasePage):
2523 HANDWRITTEN_DOC1 = "//body[1]/div[2]/div[1]/main[1]/div[1]/div[2]/div[4]/div[1]/div[1]/div[1]/div[2]/div[2]/span[1]"
2624 HANDWRITTEN_DOC2 = "//body[1]/div[2]/div[1]/main[1]/div[1]/div[2]/div[4]/div[1]/div[1]/div[2]/div[2]/div[2]/span[1]"
2725 HANDWRITTEN_DOC3 = "//body[1]/div[2]/div[1]/main[1]/div[1]/div[2]/div[4]/div[1]/div[1]/div[6]/div[2]/div[2]/span[1]"
28- SEND_BUTTON = "//button[@aria-label='Send']"
26+ SEND_BUTTON = "( //button[@aria-label='Send'])[1 ]"
2927 POP_UP_CHAT_SEARCH = "(//textarea[@placeholder='Ask a question or request (ctrl + enter to submit)'])[2]"
3028 POP_UP_CHAT_SEND = "(//button[@type='submit'])[2]"
3129 DOCUMENT_FILTER = "//button[normalize-space()='Accessibility Features']"
3230 HEADING_TITLE = "//div[.='Document Knowledge Mining']"
31+ UPLOAD_BUTTON = "//button[contains(text(), 'Upload')]"
32+ FILE_INPUT = "input[type='file']"
33+ CLEAR_ALL_BUTTON = "//button[normalize-space()='Clear all']"
34+ SEARCH_CLEAR = "//button[@aria-label='Clear']"
35+ TIME_FILTER = "//button[contains(text(), 'Anytime')]"
3336
3437 def __init__ (self , page ):
3538 self .page = page
@@ -41,7 +44,10 @@ def validate_home_page(self):
4144 self .page .wait_for_timeout (2000 )
4245
4346 def enter_a_question (self , text ):
44- self .page .locator (self .ASK_QUESTION ).fill (text )
47+ # Close any blocking dialogs first
48+ self .close_dialog_if_open ()
49+ # Target the main page textarea
50+ self .page .locator (self .ASK_QUESTION ).first .fill (text )
4551 self .page .wait_for_timeout (5000 )
4652
4753 def enter_in_search (self , text ):
@@ -55,6 +61,8 @@ def enter_in_popup_search(self, text):
5561 # self.page.wait_for_load_state('networkidle')
5662
5763 def select_housing_checkbox (self ):
64+ # Close any blocking dialogs first
65+ self .close_dialog_if_open ()
5866 self .page .locator (self .HOUSING_2022 ).click ()
5967 self .page .locator (self .HOUSING_2023 ).click ()
6068 self .page .wait_for_timeout (5000 )
@@ -81,8 +89,10 @@ def select_handwritten_doc(self):
8189 self .page .wait_for_timeout (2000 )
8290
8391 def click_send_button (self ):
92+ # Close any blocking dialogs first
93+ self .close_dialog_if_open ()
8494 # Click on send button in question area
85- self .page .locator (self .SEND_BUTTON ).click ()
95+ self .page .locator (self .SEND_BUTTON ).first . click ()
8696 self .page .wait_for_timeout (5000 )
8797
8898 # self.page.wait_for_load_state('networkidle')
@@ -143,3 +153,85 @@ def click_suggested_question(self):
143153 def click_on_contract_details (self ):
144154 self .page .locator (self .CONTRACTS_DETAILS_PAGE ).click ()
145155 self .page .wait_for_timeout (12000 )
156+
157+ def click_upload_button (self ):
158+ """Click the upload documents button"""
159+ self .page .locator (self .UPLOAD_BUTTON ).click ()
160+ self .page .wait_for_timeout (2000 )
161+
162+ def upload_file (self , file_path ):
163+ """Upload a file using file input"""
164+ with self .page .expect_file_chooser () as fc_info :
165+ self .page .locator (self .FILE_INPUT ).click ()
166+ file_chooser = fc_info .value
167+ file_chooser .set_files (file_path )
168+ self .page .wait_for_timeout (3000 )
169+
170+ def upload_multiple_files (self , file_paths ):
171+ """Upload multiple files"""
172+ with self .page .expect_file_chooser () as fc_info :
173+ self .page .locator (self .FILE_INPUT ).click ()
174+ file_chooser = fc_info .value
175+ file_chooser .set_files (file_paths )
176+ self .page .wait_for_timeout (5000 )
177+
178+ def click_clear_all (self ):
179+ """Click the Clear All button"""
180+ self .page .locator (self .CLEAR_ALL_BUTTON ).click ()
181+ self .page .wait_for_timeout (2000 )
182+
183+ def clear_search_box (self ):
184+ """Clear the search box"""
185+ self .page .locator (self .SEARCH_BOX ).fill ("" )
186+ self .page .wait_for_timeout (2000 )
187+
188+ def close_dialog_if_open (self ):
189+ """Close any open dialog/modal popup"""
190+ try :
191+ # Check if dialog exists and is visible
192+ dialog = self .page .locator ("div[role='dialog'][aria-modal='true']" )
193+ if dialog .is_visible (timeout = 2000 ):
194+ # Try to close via close button
195+ close_button = dialog .locator ("button[aria-label='close'], button[aria-label='Close']" )
196+ if close_button .is_visible (timeout = 1000 ):
197+ close_button .click ()
198+ self .page .wait_for_timeout (1000 )
199+ else :
200+ # Try pressing Escape key
201+ self .page .keyboard .press ("Escape" )
202+ self .page .wait_for_timeout (1000 )
203+ except :
204+ # No dialog open, continue
205+ pass
206+
207+ def verify_send_button_disabled (self ):
208+ """Verify send button is disabled (checking main page button, not popup)"""
209+ # Close any dialogs first
210+ self .close_dialog_if_open ()
211+ # Target the main page send button specifically
212+ send_button = self .page .locator (self .SEND_BUTTON ).first
213+ # The send button might not have disabled attribute, check if it's clickable
214+ # In some apps, the button stays enabled but backend validation prevents submission
215+ try :
216+ # Check if button has disabled attribute
217+ is_disabled = send_button .get_attribute ("disabled" ) is not None
218+ if is_disabled :
219+ return True
220+ # If no disabled attribute, check aria-disabled
221+ aria_disabled = send_button .get_attribute ("aria-disabled" )
222+ if aria_disabled == "true" :
223+ return True
224+ # If neither, the button is enabled in UI - return False
225+ return False
226+ except :
227+ return False
228+
229+ def verify_send_button_enabled (self ):
230+ """Verify send button is enabled (checking main page button, not popup)"""
231+ # Close any dialogs first
232+ self .close_dialog_if_open ()
233+ # Target the main page send button specifically
234+ send_button = self .page .locator (self .SEND_BUTTON ).first
235+ # Check the disabled attribute
236+ is_disabled = send_button .get_attribute ("disabled" ) is not None
237+ return not is_disabled
0 commit comments