From ec9c83279a2e9c98d9ae5196216fb0d975f7eefe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Fri, 20 Dec 2024 16:28:41 +0000 Subject: [PATCH] fix(e2e): Drop index, use last. Match by value without using fill() --- e2e/tests/ui-driven/src/helpers/addComponent.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/e2e/tests/ui-driven/src/helpers/addComponent.ts b/e2e/tests/ui-driven/src/helpers/addComponent.ts index 9058eb1e08..32b979e958 100644 --- a/e2e/tests/ui-driven/src/helpers/addComponent.ts +++ b/e2e/tests/ui-driven/src/helpers/addComponent.ts @@ -394,20 +394,13 @@ async function createComponentOptionsWithDataValues( page: Page, options: OptionWithDataValues[], ) { - let index = 0; for (const option of options) { await page.locator("button").filter({ hasText: "add new" }).click(); - await page.getByPlaceholder("Option").nth(index).fill(option.optionText); - await page.getByRole("combobox", { name: "Data field" }).nth(index).click(); - await page - .getByRole("combobox", { name: "Data field" }) - .nth(index) - .fill(option.dataValue); + await page.getByPlaceholder("Option").last().fill(option.optionText); + await page.getByRole("combobox", { name: "Data field" }).last().click(); await page - .getByRole("combobox", { name: "Data field" }) - .nth(index) - .press("Enter"); - index++; + .getByRole("option", { name: option.dataValue, exact: true }) + .click(); } }