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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

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 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
if (selectedValue !== 'five') {
throw new Error('Expected "five" but got ' + selectedValue);
}
await options.selectOption({value:'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.

TODO(olegbespalov): adjust the tests to pick different select options to check that we actually pick the intendant one, but not checking the "five" from the previous working pick

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