1- from base .base import BasePage
2- from playwright .sync_api import expect
31import time
2+
43from playwright .sync_api import TimeoutError as PlaywrightTimeoutError
4+ from playwright .sync_api import expect
5+
6+ from base .base import BasePage
7+
58
69class DkmPage (BasePage ):
710 WELCOME_PAGE_TITLE = "(//div[@class='order-5 my-auto pb-3 text-lg font-semibold leading-tight text-white mt-3'])[1]"
811 NEWTOPIC = "//button[normalize-space()='New Topic']"
9- Suggested_follow_up_questions = "body > div:nth-child(3) > div:nth-child(1) > main:nth-child(2) > div:nth-child(1) > div:nth-child(3) > 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)"
12+ Suggested_follow_up_questions = "body > div:nth-child(3) > div:nth-child(1) > main:nth-child(2) > div:nth-child(1) > div:nth-child(3) > 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)"
1013 SCROLL_DOWN = "//div[10]//div[2]//div[2]//i[1]//img[1]"
11- ASK_QUESTION = "//textarea[@placeholder='Ask a question or request (ctrl + enter to submit)']"
12- SEARCH_BOX = "//input[@type='search']"
13- HOUSING_2022 = "//body[1]/div[2]/div[1]/main[1]/div[1]/div[2]/div[4]/div[1]/div[1]/div[4]/div[2]/div[2]/span[1]"
14- HOUSING_2023 = "//body[1]/div[2]/div[1]/main[1]/div[1]/div[2]/div[4]/div[1]/div[1]/div[3]/div[2]/div[2]/span[1]"
14+ ASK_QUESTION = (
15+ "//textarea[@placeholder='Ask a question or request (ctrl + enter to submit)']"
16+ )
17+ SEARCH_BOX = "//input[@type='search']"
18+ HOUSING_2022 = "//body[1]/div[2]/div[1]/main[1]/div[1]/div[2]/div[4]/div[1]/div[1]/div[4]/div[2]/div[2]/span[1]"
19+ HOUSING_2023 = "//body[1]/div[2]/div[1]/main[1]/div[1]/div[2]/div[4]/div[1]/div[1]/div[3]/div[2]/div[2]/span[1]"
1520 CONTRACTS_DETAILS_PAGE = "body > div:nth-child(3) > div:nth-child(1) > main:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(4) > div:nth-child(1) > div:nth-child(1) > div:nth-child(6) > div:nth-child(2) > div:nth-child(2) > div:nth-child(3) > button:nth-child(2)"
16- DETAILS_PAGE = "body > div:nth-child(3) > div:nth-child(1) > main:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(4) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > div:nth-child(2) > div:nth-child(2) > div:nth-child(3) > button:nth-child(2)"
17- POP_UP_CHAT = "//button[@value='Chat Room']"
18- CLOSE_POP_UP = "//button[@aria-label='close']"
19- CLLEAR_ALL_POP_UP = "//button[normalize-space()='Clear all']"
20- HANDWRITTEN_DOC1 = "//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]"
21- HANDWRITTEN_DOC2 = "//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]"
22- HANDWRITTEN_DOC3 = "//body[1]/div[2]/div[1]/main[1]/div[1]/div[2]/div[4]/div[1]/div[1]/div[5]/div[2]/div[2]/span[1]"
21+ DETAILS_PAGE = "body > div:nth-child(3) > div:nth-child(1) > main:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(4) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > div:nth-child(2) > div:nth-child(2) > div:nth-child(3) > button:nth-child(2)"
22+ POP_UP_CHAT = "//button[@value='Chat Room']"
23+ CLOSE_POP_UP = "//button[@aria-label='close']"
24+ CLLEAR_ALL_POP_UP = "//button[normalize-space()='Clear all']"
25+ HANDWRITTEN_DOC1 = "//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]"
26+ HANDWRITTEN_DOC2 = "//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]"
27+ HANDWRITTEN_DOC3 = "//body[1]/div[2]/div[1]/main[1]/div[1]/div[2]/div[4]/div[1]/div[1]/div[5]/div[2]/div[2]/span[1]"
2328 SEND_BUTTON = "//button[@aria-label='Send']"
2429 POP_UP_CHAT_SEARCH = "(//textarea[@placeholder='Ask a question or request (ctrl + enter to submit)'])[2]"
2530 POP_UP_CHAT_SEND = "(//button[@type='submit'])[2]"
2631 DOCUMENT_FILTER = "//button[normalize-space()='Accessibility Features']"
2732 HEADING_TITLE = "//div[.='Document Knowledge Mining']"
28-
29-
33+
3034 def __init__ (self , page ):
3135 self .page = page
3236
33-
34-
3537 def validate_home_page (self ):
3638 self .page .wait_for_timeout (5000 )
37- expect (self .page .locator (self .DOCUMENT_FILTER )).to_be_visible ()
39+ # expect(self.page.locator(self.DOCUMENT_FILTER)).to_be_visible()
3840 expect (self .page .locator (self .HEADING_TITLE )).to_be_visible ()
3941 self .page .wait_for_timeout (2000 )
4042
41-
42- def enter_a_question (self ,text ):
43+ def enter_a_question (self , text ):
4344 self .page .locator (self .ASK_QUESTION ).fill (text )
4445 self .page .wait_for_timeout (5000 )
4546
46- def enter_in_search (self ,text ):
47+ def enter_in_search (self , text ):
4748 self .page .locator (self .SEARCH_BOX ).fill (text )
4849 self .page .wait_for_timeout (5000 )
4950
50- def enter_in_popup_search (self ,text ):
51+ def enter_in_popup_search (self , text ):
5152 self .page .locator (self .POP_UP_CHAT_SEARCH ).fill (text )
5253 self .page .wait_for_timeout (5000 )
5354 self .page .locator (self .POP_UP_CHAT_SEND ).click ()
@@ -67,7 +68,7 @@ def click_on_popup_chat(self):
6768 self .page .locator (self .POP_UP_CHAT ).click ()
6869 self .page .wait_for_timeout (5000 )
6970
70- def close_pop_up (self ):
71+ def close_pop_up (self ):
7172 self .page .locator (self .CLOSE_POP_UP ).click ()
7273 self .page .wait_for_timeout (2000 )
7374 self .page .locator (self .CLLEAR_ALL_POP_UP ).click ()
@@ -78,15 +79,15 @@ def select_handwritten_doc(self):
7879 self .page .locator (self .HANDWRITTEN_DOC2 ).click ()
7980 self .page .locator (self .HANDWRITTEN_DOC3 ).click ()
8081 self .page .wait_for_timeout (2000 )
81-
82+
8283 def click_send_button (self ):
8384 # Click on send button in question area
8485 self .page .locator (self .SEND_BUTTON ).click ()
8586 self .page .wait_for_timeout (5000 )
8687
87- #self.page.wait_for_load_state('networkidle')
88+ # self.page.wait_for_load_state('networkidle')
8889
89- def wait_until_response_loaded (self ,timeout = 200000 ):
90+ def wait_until_response_loaded (self , timeout = 200000 ):
9091 start_time = time .time ()
9192 interval = 0.1
9293 end_time = start_time + timeout / 1000
@@ -97,17 +98,18 @@ def wait_until_response_loaded(self,timeout=200000):
9798 return
9899 time .sleep (interval )
99100
100- raise PlaywrightTimeoutError ("Response is not generated and it has been timed out." )
101+ raise PlaywrightTimeoutError (
102+ "Response is not generated and it has been timed out."
103+ )
101104 # try:
102105 # # Wait for it to appear in the DOM and be visible
103106 # locator = self.page.locator(self.ASK_QUESTION)
104107 # locator.wait_for(state="enabled", timeout=200000) # adjust timeout as needed
105108 # except PlaywrightTimeoutError:
106109 # raise Exception("Response is not generated and it has been timed out.")
107-
108-
109- def wait_until_chat_details_response_loaded (self ,timeout = 200000 ):
110-
110+
111+ def wait_until_chat_details_response_loaded (self , timeout = 200000 ):
112+
111113 start_time = time .time ()
112114 interval = 0.1
113115 end_time = start_time + timeout / 1000
@@ -118,30 +120,26 @@ def wait_until_chat_details_response_loaded(self,timeout=200000):
118120 return
119121 time .sleep (interval )
120122
121- raise PlaywrightTimeoutError ("Response is not generated and it has been timed out." )
122-
123-
123+ raise PlaywrightTimeoutError (
124+ "Response is not generated and it has been timed out."
125+ )
124126
125127 def click_new_topic (self ):
126128 self .page .locator (self .NEWTOPIC ).click ()
127129 self .page .wait_for_timeout (2000 )
128- self .page .wait_for_load_state (' networkidle' )
130+ self .page .wait_for_load_state (" networkidle" )
129131
130132 def get_follow_ques_text (self ):
131- follow_up_question = self .page .locator (self .Suggested_follow_up_questions ).text_content ()
133+ follow_up_question = self .page .locator (
134+ self .Suggested_follow_up_questions
135+ ).text_content ()
132136 return follow_up_question
133137
134- def click_suggested_question (self ):
138+ def click_suggested_question (self ):
135139 self .page .locator (self .Suggested_follow_up_questions ).click ()
136140 self .page .wait_for_timeout (2000 )
137- self .page .wait_for_load_state ('networkidle' )
138-
139-
141+ self .page .wait_for_load_state ("networkidle" )
140142
141143 def click_on_contract_details (self ):
142144 self .page .locator (self .CONTRACTS_DETAILS_PAGE ).click ()
143145 self .page .wait_for_timeout (12000 )
144-
145-
146-
147-
0 commit comments