-
Notifications
You must be signed in to change notification settings - Fork 41
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 propagation of page timeout #1033
Conversation
The timeout to the underlying frame manager and frames that page relied on was not being propagated if page.setDefaultTimeout or page.setDefaultNavigationTimeout were being called. This fix ensures that the correct timeout structure is passed to the underlying objects that the page relies on. Closes: #940
This tests ensures that the timeout that is set in page is propagated to the underlying objects (frame manager and frame). There is one issue which is that the timeout is set in milliseconds but later it is translated into a second. This needs to be resolved in a new PR.
This tests ensures that the timeout that is set in browserContext is propagated to the underlying objects (frame manager and frame).
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 🥳
Suggestion 1: Can you merge the (almost) duplicated test code for better maintainability? Suggestion: Run the same test with page
and browserContext
in the same test.
Suggestion 2: Should we update the fillform example with this timeout setting and a comment on top of it?
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();
context.setDefaultTimeout(1);
const page = context.newPage();
try {
// page.setDefaultTimeout(1);
await page.goto('https://test.k6.io', { waitUntil: 'networkidle' });
page.waitForSelector("div[class$='overlay-box']");
} finally {
page.close();
}
}
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.
I wanted to highlight that although they seem the same, they're in fact not the same. The tests for
Happy to do this, just wondering what the hope is by doing that? |
Ah, OK, makes sense 👍
I thought it might be helpful, but it's fine. |
What?
When working with the following APIs, the timeout was being set, but it wasn't then being propagated to the underlying
frameManager
andframe
s which meant that APIs the relied on the timeout were always working with the default 30 second timeout or the timeout set in thebrowserContext
.Why?
We want to be able to set the timeouts on the
page
and affect it's APIs, while also having a different timeout on itsbrowserContext
. This is the behaviour that we want, and at the moment the setting of timeouts through thepage
object does nothing.Checklist
Related PR(s)/Issue(s)
Closes: #940