From 821bed12df657f98324804abbf9f186ae276f437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Werner?= Date: Mon, 27 May 2024 15:31:30 +0000 Subject: [PATCH] wait until option value is loaded for select inputs --- src/commands/texei/cpqsettings/set.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/commands/texei/cpqsettings/set.ts b/src/commands/texei/cpqsettings/set.ts index b26fcc5..9608ff7 100644 --- a/src/commands/texei/cpqsettings/set.ts +++ b/src/commands/texei/cpqsettings/set.ts @@ -155,10 +155,14 @@ export default class Set extends SfCommand { this.spinner.stop('Text Value already ok'); } } else if (targetType === 'select') { - await targetInput.waitForSelector(`xpath///option[text()='${cpqSettings[tabKey][key]}']`); - const selectedOptionValue = await (await targetInput?.getProperty('value'))?.jsonValue(); + // wait until option value is loaded and get select input for further processing + await page.waitForXPath(`${xpath}//option[text()='${cpqSettings[tabKey][key]}']`); + const targetSelectInputs = await page.$x(xpath); + const targetSelectInput = targetSelectInputs[0] as ElementHandle; - const selectedOptionElement = await targetInput.$(`option[value='${selectedOptionValue}']`); + const selectedOptionValue = await (await targetSelectInput?.getProperty('value'))?.jsonValue(); + + const selectedOptionElement = await targetSelectInput.$(`option[value='${selectedOptionValue}']`); currentValue = (await (await selectedOptionElement?.getProperty('text'))?.jsonValue()) as string; if (currentValue !== cpqSettings[tabKey][key]) { @@ -168,10 +172,10 @@ export default class Set extends SfCommand { ); const optionElement = ( - await targetInput.$$(`xpath///option[text()='${cpqSettings[tabKey][key]}']`) + await targetSelectInput.$$(`xpath///option[text()='${cpqSettings[tabKey][key]}']`) )[0] as ElementHandle; const optionValue = await (await optionElement.getProperty('value')).jsonValue(); - await targetInput.select(optionValue); + await targetSelectInput.select(optionValue); this.spinner.stop(`Picklist Value updated from ${currentValue} to ${cpqSettings[tabKey][key]}`); } else {