-
Notifications
You must be signed in to change notification settings - Fork 42
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
Fix reload & setContent to use navigation timeout #1034
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested this with the following script, and it worked 🥳 Nice catch!
I've also checked the other methods we have by exploring the link you shared, and they all seem fine and use the correct timeout 👍
import { browser } from 'k6/x/browser';
export const options = {
scenarios: {
ui: {
executor: 'per-vu-iterations',
vus: 1,
iterations: '1',
options: {
browser: {
type: 'chromium',
},
},
},
}
};
export default async function() {
const context = browser.newContext();
const page = context.newPage();
try {
await page.goto('https://test.k6.io', { waitUntil: 'networkidle' });
context.setDefaultNavigationTimeout(0.1); // <---
page.reload();
} finally {
page.close();
}
}
I wish we had a better error message (concise and without the first execution context changed error) when the navigation timeout happens :) Current one:
WARN[0002] failed to hide page: evaluating JS: execution context changed; most likely because of a navigation category="Page:Close" elapsed="0 ms" source=browser
ERRO[0002] Uncaught (in promise) GoError: reloading page: timed out
at github.com/grafana/xk6-browser/browser.mapPage.func9 (native)
at file:///Users/inanc/grafana/k6browser/tests/pr1034.js:24:4(27) executor=per-vu-iterations scenario=ui
213fbc5
to
3994fd6
Compare
These methods should work with the default navigation instead of the default timeout to match the behaviour in Playwright.
3994fd6
to
499d0d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Remember to squash as there is a fix-up commit :)
What?
The following page APIs were not using the correct timeout:
Why?
These methods should work with the default navigation instead of the default timeout to match the behaviour in Playwright.
Checklist
Related PR(s)/Issue(s)