Skip to content
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

fixes panic for the selectOption #1552

Merged
merged 6 commits into from
Dec 10, 2024
Merged

fixes panic for the selectOption #1552

merged 6 commits into from
Dec 10, 2024

Conversation

olegbespalov
Copy link
Contributor

@olegbespalov olegbespalov commented Nov 28, 2024

What?

This PR aims to fix the panic from #1415, by trying to stick with the types that we explicitly mention in our documentation https://grafana.com/docs/k6/latest/javascript-api/k6-browser/locator/selectoption/

Why?

We shouldn't panic

Checklist

  • I have performed a self-review of my code
  • I have added tests for my changes
  • I have commented on my code, particularly in hard-to-understand areas

Related PR(s)/Issue(s)

Closes #1415

Fixes #grafana/k6#4071

common/tests/cmd_test.go Outdated Show resolved Hide resolved
const page = await browser.newPage();
await page.goto('https://test.k6.io/browser.php');
const options = page.locator('#numbers-options');
await options.selectOption({label:'Five'});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ankur22 @inancgumus any tips on how to better test this keeping in mind the current test structure?

I took a look into the tests package and not sure what could be the best way to emulate input like that (and below).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, I've created this to be like the ones that k6-core uses.

My predominant concern is why it should start from JS is because partially the panic was caused because of some "magic" sobek type transitioning, and I'd like to keep it as part of the test, to ensure that it works

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like how you wrote the test, it's much more succinct to how we do it.

If we can't sort the race condition out, then take a look at a test that works with startIteration, such as TestPageOnMetric.

@olegbespalov olegbespalov force-pushed the fix/panic-selectOption branch from 407f2ef to cdc2413 Compare November 28, 2024 15:53
@olegbespalov olegbespalov marked this pull request as ready for review November 29, 2024 15:19
@olegbespalov olegbespalov requested a review from a team as a code owner November 29, 2024 15:19
@olegbespalov olegbespalov self-assigned this Nov 29, 2024
tests/locator_test.go Outdated Show resolved Hide resolved
@olegbespalov olegbespalov force-pushed the fix/panic-selectOption branch from 8cbfc57 to 2223948 Compare December 10, 2024 14:36
Copy link
Collaborator

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@ankur22 ankur22 merged commit 40795d5 into main Dec 10, 2024
23 checks passed
@ankur22 ankur22 deleted the fix/panic-selectOption branch December 10, 2024 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to selectOption using object
2 participants