@@ -20,6 +20,10 @@ class WebUserPage(BasePage):
20
20
CHAT_HISTORY_OPTIONS = "//button[@id='moreButton']"
21
21
CHAT_HISTORY_DELETE = "//button[@role='menuitem']"
22
22
23
+ TOGGLE_CITATIONS_LIST = "[data-testid='toggle-citations-list']"
24
+ CITATIONS_CONTAINER = "[data-testid='citations-container']"
25
+ CITATION_BLOCK = "[data-testid='citation-block']"
26
+
23
27
def __init__ (self , page ):
24
28
self .page = page
25
29
self .soft_assert_errors = []
@@ -76,3 +80,47 @@ def delete_chat_history(self):
76
80
self .page .get_by_label ("hide button" ).click ()
77
81
self .page .wait_for_load_state ("networkidle" )
78
82
self .page .wait_for_timeout (2000 )
83
+
84
+ def click_reference_link_in_response (self ):
85
+ response_blocks = self .page .locator (self .ANSWER_TEXT )
86
+ last_response = response_blocks .nth (response_blocks .count () - 1 )
87
+ toggle_button = last_response .locator (self .TOGGLE_CITATIONS_LIST )
88
+ citations_container = last_response .locator (self .CITATIONS_CONTAINER )
89
+
90
+
91
+ if not citations_container .is_visible ():
92
+ toggle_button .click ()
93
+ self .page .wait_for_timeout (1000 )
94
+
95
+ citation = citations_container .locator (self .CITATION_BLOCK ).first
96
+
97
+
98
+ citation .click ()
99
+ self .page .wait_for_load_state ('networkidle' )
100
+ self .page .wait_for_timeout (2000 )
101
+
102
+ def close_citation (self ):
103
+ self .page .wait_for_timeout (3000 )
104
+ close_btn = self .page .locator (self .CLOSE_CITATIONS )
105
+ close_btn .wait_for (state = "attached" , timeout = 5000 )
106
+ close_btn .scroll_into_view_if_needed ()
107
+ close_btn .click (force = True )
108
+ self .page .wait_for_timeout (5000 )
109
+
110
+ def has_reference_link (self ):
111
+ response_blocks = self .page .locator (self .ANSWER_TEXT )
112
+
113
+ count = response_blocks .count ()
114
+ if count == 0 :
115
+ return False
116
+ last_response = response_blocks .nth (count - 1 )
117
+ toggle_button = last_response .locator (self .TOGGLE_CITATIONS_LIST )
118
+ if toggle_button .count () > 0 :
119
+ toggle_button .click ()
120
+
121
+
122
+ citations_container = last_response .locator (self .CITATIONS_CONTAINER )
123
+ citation_blocks = citations_container .locator (self .CITATION_BLOCK )
124
+ citation_count = citation_blocks .count ()
125
+
126
+ return citation_count > 0
0 commit comments