diff --git a/backend/services/clickTtPlayerRegistrationService.js b/backend/services/clickTtPlayerRegistrationService.js index 486345ac..0cf2bb56 100644 --- a/backend/services/clickTtPlayerRegistrationService.js +++ b/backend/services/clickTtPlayerRegistrationService.js @@ -412,7 +412,7 @@ class ClickTtPlayerRegistrationService { if (await nationalitySelect.count()) { const currentValue = await nationalitySelect.inputValue().catch(() => 'WONoSelectionString'); if (!currentValue || currentValue === 'WONoSelectionString') { - await nationalitySelect.selectOption({ label: /Deutschland/ }); + await this._selectOptionByLabelContains(nationalitySelect, 'Deutschland'); } } @@ -420,7 +420,7 @@ class ClickTtPlayerRegistrationService { if (await countrySelect.count()) { const currentValue = await countrySelect.inputValue().catch(() => 'WONoSelectionString'); if (!currentValue || currentValue === 'WONoSelectionString') { - await countrySelect.selectOption({ label: /Deutschland/ }); + await this._selectOptionByLabelContains(countrySelect, 'Deutschland'); } } @@ -512,6 +512,27 @@ class ClickTtPlayerRegistrationService { return true; } + async _selectOptionByLabelContains(locator, text) { + if (!(await locator.count())) { + return false; + } + + const optionValue = await locator.evaluate((select, searchText) => { + const normalizedSearch = String(searchText || '').toLowerCase(); + const option = Array.from(select.options).find((entry) => + String(entry.textContent || '').toLowerCase().includes(normalizedSearch) + ); + return option?.value || null; + }, text); + + if (!optionValue) { + return false; + } + + await locator.selectOption(optionValue); + return true; + } + async _hasTextTarget(page, text) { const escaped = escapeRegExp(text); const selectors = [