From d9ed30ab002f785d2eb7b8cdaed8feaae8cd5d4c Mon Sep 17 00:00:00 2001 From: Tatu Aalto Date: Sat, 19 Feb 2022 22:36:49 +0200 Subject: [PATCH] Not all select elements has value attribute But out code assumes so Fixes #1622 --- atest/test/02_Content_Keywords/select_lists.robot | 7 +++++-- node/dynamic-test-app/static/prefilled_email_form.html | 7 +++++++ node/playwright-wrapper/interaction.ts | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/atest/test/02_Content_Keywords/select_lists.robot b/atest/test/02_Content_Keywords/select_lists.robot index e2782581a..5e59593c7 100644 --- a/atest/test/02_Content_Keywords/select_lists.robot +++ b/atest/test/02_Content_Keywords/select_lists.robot @@ -21,7 +21,7 @@ Get Select Options Get Select Options Strict Run Keyword And Expect Error - ... *strict mode violation*//select*resolved to 3 elements* + ... *strict mode violation*//select*resolved to 4 elements* ... Get Select Options //select Set Strict Mode False ${options} = Get Select Options //select @@ -97,6 +97,9 @@ Select Options By With Nonmatching Selector ... notamatch label False Label [Teardown] Set Browser Timeout ${PLAYWRIGHT_TIMEOUT} +Select Options By Text When Select Does Not Have Value Attribute + Select Options By id=noValue text Option 2 + Deselect Options Implicitly Select Option And Verify Selection text select[name=possible_channels] @@ -106,7 +109,7 @@ Deselect Options Explicitly Deselect Options With Strict Run Keyword And Expect Error - ... *strict mode violation*//select*resolved to 3 elements* + ... *strict mode violation*//select*resolved to 4 elements* ... Deselect Options //select Set Strict Mode False Deselect Options //select diff --git a/node/dynamic-test-app/static/prefilled_email_form.html b/node/dynamic-test-app/static/prefilled_email_form.html index 847ab95e0..94cb76eb4 100644 --- a/node/dynamic-test-app/static/prefilled_email_form.html +++ b/node/dynamic-test-app/static/prefilled_email_form.html @@ -73,6 +73,13 @@ + Select without value: + + + diff --git a/node/playwright-wrapper/interaction.ts b/node/playwright-wrapper/interaction.ts index dc9909285..181f6aaa3 100644 --- a/node/playwright-wrapper/interaction.ts +++ b/node/playwright-wrapper/interaction.ts @@ -38,7 +38,7 @@ export async function selectOption( const attributeName = Object.keys(matcher[0])[0]; const selectedOptions = []; for (const selectedOption of result) { - const locatorOptions = locator.locator(`option[value="${selectedOption}"]`); + const locatorOptions = locator.locator(`//option[@value="${selectedOption}" or text()="${selectedOption}"]`); const element = await locatorOptions.elementHandle(); exists(element, `The ${selectedOption} option element did not exist.`); selectedOptions.push(String(await element.getProperty(attributeName)));