-
-
Notifications
You must be signed in to change notification settings - Fork 737
fix(webApi): selectOption method #4157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Or we can get value from optionToSelect = await el.locator('option', { hasText: option }).getAttribute('value'); What do you think? |
I guess the other Web helpers may get the same error, would you mind checking it? and add tests for it here https://github.com/codeceptjs/CodeceptJS/blob/3.x/test/helper/webapi.js#L391 |
I will try. |
trim text content value
@kobenguyent please take a look. I have run tests local, all works good. Only |
thanks @dyaroman! |
* updated performSwipe with w3c protocol * chore(deps-dev): bump @wdio/utils from 8.27.2 to 8.28.8 (#4152) * fix: I.say would be added to Test.steps object (#4145) * release 3.5.12 (#4156) * release 3.5.12 * fix(webapi): selectOption method (#4157) trim text content value * DOC: Update contributor faces * fixed typescript parameter inputs count * chore(deps-dev): bump testcafe from 3.3.0 to 3.5.0 (#4160) Bumps [testcafe](https://github.com/DevExpress/testcafe) from 3.3.0 to 3.5.0. - [Release notes](https://github.com/DevExpress/testcafe/releases) - [Changelog](https://github.com/DevExpress/testcafe/blob/master/CHANGELOG.md) - [Commits](DevExpress/testcafe@v3.3.0...v3.5.0) --- updated-dependencies: - dependency-name: testcafe dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * updated performSwipe with w3c protocol * fixed typescript parameter inputs count * chore(deps-dev): bump @wdio/sauce-service from 8.27.0 to 8.29.1 (#4161) * removed elementId parameter * updated performSwipe with w3c protocol * fixed typescript parameter inputs count * removed elementId parameter * run mobile tests * run mobile tests * run mobile tests * tweak ci --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: KobeN <7845001+kobenguyent@users.noreply.github.com> Co-authored-by: Roman Diachenko <dyaroman@gmail.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: kobenguyent <kobenguyent@gmail.com>
Motivation/Description of the PR
I was trying to select an option by value '1999' from year of birth select and I used Playwright 'selectOption' method for this. But I got error:

Then I debugged method 'selectOption' and found that '.textContent()' method return value with spaces: ' 1999 ', that why I got error. I think this is a realistic case, many template engines can produce additional spaces.
Here HTML of select element:

I suggest to trim the value returned by the 'textContent' method. If 'textContent' returned 'null' we will get type error, but 'catch' block will catch this error and return 'option' argument.
What do you think?
CodeceptJS/lib/helper/Playwright.js
Line 1808 in 439364e
Applicable helpers:
Applicable plugins:
Type of change
Checklist:
npm run docs
)npm run lint
)npm test
)