diff --git a/packages/injected/src/injectedScript.ts b/packages/injected/src/injectedScript.ts index 732155168dfa7..1619e5287eb0e 100644 --- a/packages/injected/src/injectedScript.ts +++ b/packages/injected/src/injectedScript.ts @@ -786,16 +786,18 @@ export class InjectedScript { let remainingOptionsToSelect = optionsToSelect.slice(); for (let index = 0; index < options.length; index++) { const option = options[index]; + const normalizedOptionLabel = normalizeWhiteSpace(option.label); const filter = (optionToSelect: Node | { valueOrLabel?: string, value?: string, label?: string, index?: number }) => { if (optionToSelect instanceof Node) return option === optionToSelect; + const matchesLabel = (label: string) => label === option.label || normalizeWhiteSpace(label) === normalizedOptionLabel; let matches = true; if (optionToSelect.valueOrLabel !== undefined) - matches = matches && (optionToSelect.valueOrLabel === option.value || optionToSelect.valueOrLabel === option.label); + matches = matches && (optionToSelect.valueOrLabel === option.value || matchesLabel(optionToSelect.valueOrLabel)); if (optionToSelect.value !== undefined) matches = matches && optionToSelect.value === option.value; if (optionToSelect.label !== undefined) - matches = matches && optionToSelect.label === option.label; + matches = matches && matchesLabel(optionToSelect.label); if (optionToSelect.index !== undefined) matches = matches && optionToSelect.index === index; return matches; diff --git a/tests/assets/input/select.html b/tests/assets/input/select.html index 53dd06adf6ff9..42784c28f376d 100644 --- a/tests/assets/input/select.html +++ b/tests/assets/input/select.html @@ -20,6 +20,7 @@ +