Not able to increase default timeout

const browser = chromium.launch({
headless: false,
timeout: ‘2m’
});

i still get
ERRO[0034] Uncaught (in promise) waiting for function, polling: timed out after 30000ms executor=per-vu-iterations scenario=browser

can someone help me to override default timeout

Hi @arvind_patel,

Could you please send us the whole script after removing possibly sensitive parts? Thanks.

@inanc

import { chromium } from 'k6/experimental/browser';
import { check, sleep, expect } from 'k6';
import exec from 'k6/execution';

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

export async function browser() {
  console.log('---------------------- user no ------------------ ' + exec.vu.idInTest);
  const browser = chromium.launch({
    headless: false,
    timeout: '2m',
    userDataDir: "'./chromeProfiles'" + exec.vu.idInTest,
  });
  const context = browser.newContext(); //one browser instance
  const page = context.newPage(); // one tab

  page.setViewportSize({
    width: 800,
    height: 720,
  }); try {
    page.setDefaultTimeout(90000);

    await page.goto('https://www.google.com/', { waitUntil: 'networkidle' });
    page.waitForSelector("div[class$='overlay-box']");
    page.waitForNavigation();
    await page.waitForFunction('document.querySelector("div[class$=****]") === null');  // wait till the overlay go away
    page.waitForSelector("#****");
    await page.mouse.move(500, 300);
    await page.mouse.click(500, 300);
    console.log('--------------vu number : ' + exec.vu.idInTest);
    console.log("my page is " + context.pages().length); //no of tabs
    sleep(10);
  } finally {
    page.close();
    browser.close();
  }
}

@inanc anything i am missing ?

Hi @arvind_patel,

It looks like you’ve hit upon an issue that we were unaware of. I’ve created an issue (#940) that you can track. We’re not sure when we will be able to get to this though unfortunately.

In the meantime you can work with browserContext.setDefaultTimeout (there’s an issue (#456) with this API too, which is that it interprets the input in seconds not milliseconds). So you should be able to work with the following change where I’ve added context.setDefaultTimeout(90); after the context has been created:

export async function browser() {
  const browser = chromium.launch({
    headless: false,
    timeout: '2m',
  });
  const context = browser.newContext(); //one browser instance
  context.setDefaultTimeout(90); // 90 seconds
  const page = context.newPage(); // one tab

Cheers,
Ankur

2 Likes

@ankur thanks for the work around. it worked