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

Setting the timeout with page.setDefaultTimeout doesn't then get used anywhere #940

Closed
ankur22 opened this issue Jun 19, 2023 · 0 comments · Fixed by #1033
Closed

Setting the timeout with page.setDefaultTimeout doesn't then get used anywhere #940

ankur22 opened this issue Jun 19, 2023 · 0 comments · Fixed by #1033
Assignees
Labels
bug Something isn't working user request Requested by the community

Comments

@ankur22
Copy link
Collaborator

ankur22 commented Jun 19, 2023

Brief summary

When we set the default timeout of the page with page.setDefaultTimeout, the value is set for the page's instance of timeoutSettings. The problem is that that value isn't used anywhere else or propagated to frame.

xk6-browser version

v0.10.0

OS

NA

Chrome version

NA

Docker version and image (if applicable)

NA

Steps to reproduce the problem

When working with the following script, it timesout, which is expected since there is no such element in test.k6.io:

import { chromium } from 'k6/experimental/browser';

export const options = {
  scenarios: {
    browser: {
      executor: 'per-vu-iterations',
      exec: 'browser',
      vus: 1,
      iterations: '1'
    }
  }
};

export async function browser() {
  const browser = chromium.launch({
    headless: false,
    timeout: '2m',
  });
  const context = browser.newContext();
  const page = context.newPage();
  try {
    page.setDefaultTimeout(90000);
    await page.goto('https://test.k6.io', { waitUntil: 'networkidle' });
    page.waitForSelector("div[class$='overlay-box']");
  } finally {
    page.close();
    browser.close();
  }
}

It results in the following error:

ERRO[0000] Failed to load resource: the server responded with a status of 404 ()  browser_source=network line_number=0 source=browser stacktrace="<nil>" url="https://k6.test.io/"
ERRO[0062] Uncaught (in promise) GoError: waiting for selector "div[class$='overlay-box']": timed out after 30000ms
running at github.com/grafana/xk6-browser/browser.mapPage.func11 (native)
browser at browser (file:///Users/ankuragarwal/go/src/github.com/grafana/xk6-browser/examples/com-test.js:24:25(37))  executor=per-vu-iterations scenario=browser

Expected behaviour

The error should be since the timeout was set to 90seconds by page.setDefaultTimeout(90000);:

ERRO[0062] Uncaught (in promise) GoError: waiting for selector "div[class$='overlay-box']": timed out after 90000ms

Actual behaviour

ERRO[0062] Uncaught (in promise) GoError: waiting for selector "div[class$='overlay-box']": timed out after 30000ms
@ankur22 ankur22 added bug Something isn't working user request Requested by the community labels Jun 19, 2023
@ankur22 ankur22 assigned ankur22 and unassigned ankur22 Aug 21, 2023
@ankur22 ankur22 self-assigned this Sep 14, 2023
ankur22 added a commit that referenced this issue Sep 14, 2023
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
ankur22 added a commit that referenced this issue Sep 18, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working user request Requested by the community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant