diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Design/ExternalSystemCrudTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Design/ExternalSystemCrudTests.cs index d870f87b..489a8a86 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Design/ExternalSystemCrudTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Design/ExternalSystemCrudTests.cs @@ -35,12 +35,14 @@ public class ExternalSystemCrudTests await page.WaitForLoadStateAsync(LoadState.NetworkIdle); await Assertions.Expect(page.Locator("h4:has-text('Add External System')")).ToBeVisibleAsync(); - // Name and Endpoint URL are both input[type=text].form-control. Per - // ExternalSystemForm.razor, Name is the first text input and Endpoint URL - // is the second — select by order. - var textInputs = page.Locator("input[type=text].form-control"); - await textInputs.Nth(0).FillAsync(name); - await textInputs.Nth(1).FillAsync("https://example.invalid/api"); + // ExternalSystemForm.razor has THREE input[type=text].form-control fields + // (Name, Endpoint URL, and Auth Config JSON), so index-based selection is + // fragile. Anchor each fill to its own div.mb-3 wrapper via the field label + // so the selectors survive field reordering and uniquely match one element. + await page.Locator("div.mb-3:has(label:has-text('Name')) input[type=text].form-control") + .FillAsync(name); + await page.Locator("div.mb-3:has(label:has-text('Endpoint URL')) input[type=text].form-control") + .FillAsync("https://example.invalid/api"); await page.Locator("button.btn-success:has-text('Save')").ClickAsync();