@@ -156,6 +156,20 @@ def get_testdata_files(self):
156156 logger .info (f"Found { len (files )} files in testdata folder: { [os .path .basename (f ) for f in files ]} " )
157157 return files
158158
159+ def _get_import_dialog (self ):
160+ """
161+ Locate the Import Content dialog using both 'dialog' and 'alertdialog' roles.
162+ Fluent UI v9 with modalType='modal' renders as role='dialog', while older
163+ versions or modalType='alert' use 'alertdialog'.
164+ """
165+ dialog = self .page .get_by_role ("dialog" , name = "Import Content" )
166+ if dialog .count () > 0 :
167+ return dialog .first
168+ alertdialog = self .page .get_by_role ("alertdialog" , name = "Import Content" )
169+ if alertdialog .count () > 0 :
170+ return alertdialog .first
171+ raise Exception ("Import Content dialog not found with role 'dialog' or 'alertdialog'" )
172+
159173 def select_schema_for_file (self , file_name , schema_name ):
160174 """
161175 Select a schema from the dropdown for a specific file in the import dialog.
@@ -166,13 +180,14 @@ def select_schema_for_file(self, file_name, schema_name):
166180 """
167181 logger .info (f"Selecting schema '{ schema_name } ' for file '{ file_name } '..." )
168182
183+ dialog = self ._get_import_dialog ()
184+
169185 # Get all schema comboboxes and file labels in the import dialog
170- schema_dropdowns = self .page .get_by_role (
171- "alertdialog" , name = "Import Content"
172- ).get_by_placeholder ("Select Schema" )
173- file_labels = self .page .get_by_role (
174- "alertdialog" , name = "Import Content"
175- ).locator ("strong" )
186+ schema_dropdowns = dialog .get_by_placeholder ("Select Schema" )
187+ file_labels = dialog .locator ("strong" )
188+
189+ # Wait for file labels to appear (React state update may be async)
190+ file_labels .first .wait_for (state = "visible" , timeout = 10000 )
176191
177192 # Find the index of this file among all listed files
178193 count = file_labels .count ()
@@ -184,6 +199,8 @@ def select_schema_for_file(self, file_name, schema_name):
184199 break
185200
186201 if target_index == - 1 :
202+ dialog_text = dialog .inner_text ()
203+ logger .error (f"File '{ file_name } ' not found. Dialog content:\n { dialog_text [:500 ]} " )
187204 raise Exception (f"File '{ file_name } ' not found in import dialog" )
188205
189206 # Click on the schema dropdown for this file
@@ -249,7 +266,7 @@ def upload_files(self):
249266
250267 logger .info ("Validating upload success..." )
251268 expect (
252- self .page . get_by_role ( "alertdialog" , name = "Import Content" )
269+ self ._get_import_dialog ( )
253270 .locator ("path" )
254271 .nth (1 )
255272 ).to_be_visible ()
@@ -818,7 +835,7 @@ def validate_import_without_collection(self):
818835 validation_msg = self .page .locator (
819836 "//div[contains(text(),'Please Select') or contains(text(),'Please select')]"
820837 )
821- dialog = self .page .get_by_role ("alertdialog" )
838+ dialog = self .page .get_by_role ("dialog" ). or_ ( self . page . get_by_role ( " alertdialog") )
822839
823840 if validation_msg .count () > 0 and validation_msg .first .is_visible ():
824841 logger .info ("✓ Validation message is visible" )
@@ -864,7 +881,7 @@ def validate_schema_selection_warning(self):
864881
865882 # Validate the selected collection info message
866883 logger .info ("Validating 'Selected Collection: Auto Claim' message..." )
867- dialog = self .page . get_by_role ( "alertdialog" , name = "Import Content" )
884+ dialog = self ._get_import_dialog ( )
868885 expect (dialog ).to_be_visible ()
869886 logger .info ("✓ Import Content dialog is visible" )
870887
@@ -935,7 +952,7 @@ def validate_unsupported_file_upload(self):
935952 logger .info ("✓ Unsupported file error message is visible" )
936953 else :
937954 # Check if Import button remains disabled
938- dialog = self .page . get_by_role ( "alertdialog" , name = "Import Content" )
955+ dialog = self ._get_import_dialog ( )
939956 import_btn = dialog .locator ("//button[normalize-space()='Import']" )
940957 expect (import_btn ).to_be_disabled ()
941958 logger .info ("✓ Import button remains disabled for unsupported file" )
@@ -1060,7 +1077,7 @@ def open_import_dialog_with_files(self):
10601077
10611078 self .page .wait_for_timeout (5000 )
10621079
1063- dialog = self .page . get_by_role ( "alertdialog" , name = "Import Content" )
1080+ dialog = self ._get_import_dialog ( )
10641081 logger .info ("Import dialog opened with files ready for schema selection" )
10651082 return dialog
10661083
@@ -1158,7 +1175,7 @@ def upload_files_with_mismatched_schemas(self):
11581175
11591176 logger .info ("Validating upload success (system accepts mismatched schemas)..." )
11601177 expect (
1161- self .page . get_by_role ( "alertdialog" , name = "Import Content" )
1178+ self ._get_import_dialog ( )
11621179 .locator ("path" )
11631180 .nth (1 )
11641181 ).to_be_visible ()
0 commit comments