@@ -156,6 +156,25 @@ 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+ alertdialog = self .page .get_by_role ("alertdialog" , name = "Import Content" )
167+ import_dialog = dialog .or_ (alertdialog ).first
168+
169+ try :
170+ expect (import_dialog ).to_be_visible (timeout = 5000 )
171+ except Exception as exc :
172+ raise Exception (
173+ "Import Content dialog not found with role 'dialog' or 'alertdialog'"
174+ ) from exc
175+
176+ return import_dialog
177+
159178 def select_schema_for_file (self , file_name , schema_name ):
160179 """
161180 Select a schema from the dropdown for a specific file in the import dialog.
@@ -166,13 +185,11 @@ def select_schema_for_file(self, file_name, schema_name):
166185 """
167186 logger .info (f"Selecting schema '{ schema_name } ' for file '{ file_name } '..." )
168187
188+ dialog = self ._get_import_dialog ()
189+
169190 # 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" )
191+ schema_dropdowns = dialog .get_by_placeholder ("Select Schema" )
192+ file_labels = dialog .locator ("strong" )
176193
177194 # Find the index of this file among all listed files
178195 count = file_labels .count ()
@@ -184,6 +201,8 @@ def select_schema_for_file(self, file_name, schema_name):
184201 break
185202
186203 if target_index == - 1 :
204+ dialog_text = dialog .inner_text ()
205+ logger .error (f"File '{ file_name } ' not found. Dialog content:\n { dialog_text [:500 ]} " )
187206 raise Exception (f"File '{ file_name } ' not found in import dialog" )
188207
189208 # Click on the schema dropdown for this file
@@ -249,7 +268,7 @@ def upload_files(self):
249268
250269 logger .info ("Validating upload success..." )
251270 expect (
252- self .page . get_by_role ( "alertdialog" , name = "Import Content" )
271+ self ._get_import_dialog ( )
253272 .locator ("path" )
254273 .nth (1 )
255274 ).to_be_visible ()
@@ -818,7 +837,9 @@ def validate_import_without_collection(self):
818837 validation_msg = self .page .locator (
819838 "//div[contains(text(),'Please Select') or contains(text(),'Please select')]"
820839 )
821- dialog = self .page .get_by_role ("alertdialog" )
840+ dialog = self .page .get_by_role ("dialog" , name = "Import Content" ).or_ (
841+ self .page .get_by_role ("alertdialog" , name = "Import Content" )
842+ )
822843
823844 if validation_msg .count () > 0 and validation_msg .first .is_visible ():
824845 logger .info ("✓ Validation message is visible" )
@@ -864,7 +885,7 @@ def validate_schema_selection_warning(self):
864885
865886 # Validate the selected collection info message
866887 logger .info ("Validating 'Selected Collection: Auto Claim' message..." )
867- dialog = self .page . get_by_role ( "alertdialog" , name = "Import Content" )
888+ dialog = self ._get_import_dialog ( )
868889 expect (dialog ).to_be_visible ()
869890 logger .info ("✓ Import Content dialog is visible" )
870891
@@ -935,7 +956,7 @@ def validate_unsupported_file_upload(self):
935956 logger .info ("✓ Unsupported file error message is visible" )
936957 else :
937958 # Check if Import button remains disabled
938- dialog = self .page . get_by_role ( "alertdialog" , name = "Import Content" )
959+ dialog = self ._get_import_dialog ( )
939960 import_btn = dialog .locator ("//button[normalize-space()='Import']" )
940961 expect (import_btn ).to_be_disabled ()
941962 logger .info ("✓ Import button remains disabled for unsupported file" )
@@ -1060,7 +1081,7 @@ def open_import_dialog_with_files(self):
10601081
10611082 self .page .wait_for_timeout (5000 )
10621083
1063- dialog = self .page . get_by_role ( "alertdialog" , name = "Import Content" )
1084+ dialog = self ._get_import_dialog ( )
10641085 logger .info ("Import dialog opened with files ready for schema selection" )
10651086 return dialog
10661087
@@ -1158,7 +1179,7 @@ def upload_files_with_mismatched_schemas(self):
11581179
11591180 logger .info ("Validating upload success (system accepts mismatched schemas)..." )
11601181 expect (
1161- self .page . get_by_role ( "alertdialog" , name = "Import Content" )
1182+ self ._get_import_dialog ( )
11621183 .locator ("path" )
11631184 .nth (1 )
11641185 ).to_be_visible ()
0 commit comments