fix: Get Text returns option text instead of value for select elements#4991
Open
mvanhorn wants to merge 1 commit into
Open
fix: Get Text returns option text instead of value for select elements#4991mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
Get Text on a <select> regressed between v19.12.0 and v20.0.0: it returned the selected option's value attribute instead of the visible option text. Commit 6b5fe6b expanded the tag check in _getTextContentNoTextType to route SELECT through inputValue(); this restores the v19 behavior by letting <select> fall through to innerText(). The explicit text_type=inputValue path is unchanged for callers who still want the value attribute. Fixes MarketSquare#4953
aaltat
requested changes
Jun 23, 2026
| assert text == "element text" | ||
|
|
||
|
|
||
| def test_get_text_select_returns_option_text(ctx: MagicMock): |
Member
There was a problem hiding this comment.
Remove this test, it is not needed
| logger.info(`Getting text content without text type`); | ||
| const tag = await locator.evaluate((e) => e.tagName); | ||
| if (tag === 'SELECT' || tag === 'TEXTAREA' || tag === 'INPUT') { | ||
| // <select> intentionally falls through to innerText() to restore pre-v20 (v19.12.0) behavior per issue #4953. |
Member
There was a problem hiding this comment.
Remove comment, this is documented in tests
Member
|
@allcontributors please add @mvanhorn for code |
Contributor
|
I've put up a pull request to add @mvanhorn! 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Restores the pre-v20 behavior of
Get Texton a<select>element so it returns the visible option text instead of the selected option'svalueattribute.Why
A regression landed between Browser library v19.12.0 and v20.0.0:
Get Texton a<select>started returning the selected option'svalueattribute (e.g.value_1) instead of its visible text (e.g.Berlin). The cause is innode/playwright-wrapper/getters.ts: commit 6b5fe6b expanded the tag check in_getTextContentNoTextTypefromINPUT/TEXTAREAto also includeSELECT, routing selects throughlocator.inputValue()(the value attribute) instead ofinnerText().In v19.12.0 a
<select>fell through toinnerText(). This PR removesSELECTfrom theinputValuebranch so selects fall through toinnerText()again, matching the original behavior. The explicittext_type=inputValuepath is unchanged for callers who still want the value attribute.Changes
node/playwright-wrapper/getters.ts: narrow theinputValuebranch in_getTextContentNoTextTypeback toTEXTAREA/INPUTonly; update the fallback log message; add a comment documenting the intentional<select>fall-through.node/playwright-wrapper/__tests__/getters.test.ts: update theSELECTno-text-type unit test to expectinnerTextinstead ofinputValue.utest/test_get_text.py: add a unit test documenting that select option text is returned unchanged through the keyword wrapper.atest/test/02_Content_Keywords/basic_getters_get_text.robot: update the select acceptance assertions to check the visible option text rather than the value attribute.Fixes #4953