Skip to content

Commit

Permalink
wait until option value is loaded for select inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
André Werner committed May 27, 2024
1 parent 5c94656 commit 821bed1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/commands/texei/cpqsettings/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,14 @@ export default class Set extends SfCommand<CpqSettingsSetResult> {
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<Element>;

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]) {
Expand All @@ -168,10 +172,10 @@ export default class Set extends SfCommand<CpqSettingsSetResult> {
);

const optionElement = (
await targetInput.$$(`xpath///option[text()='${cpqSettings[tabKey][key]}']`)
await targetSelectInput.$$(`xpath///option[text()='${cpqSettings[tabKey][key]}']`)
)[0] as ElementHandle<HTMLOptionElement>;
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 {
Expand Down

0 comments on commit 821bed1

Please sign in to comment.