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

BrowserContext timeout is more lenient than in PW #445

Closed
ankur22 opened this issue Jul 7, 2022 · 1 comment
Closed

BrowserContext timeout is more lenient than in PW #445

ankur22 opened this issue Jul 7, 2022 · 1 comment
Labels
bug Something isn't working next Might be eligible for the next planning (not guaranteed!) playwright Issue relating to Playwright compatibility

Comments

@ankur22
Copy link
Collaborator

ankur22 commented Jul 7, 2022

Tested against: dbede12

If you run the following scripts then you should find that the PW script fails with a timeout error, whereas the xk6-browser script succeeds.

xk6-browser Script:

import { sleep } from 'k6';
import launcher from 'k6/x/browser';

export default function () {
  const browser = launcher.launch('chromium', {
      headless: false,
  });
  const context = browser.newContext();
  const page = context.newPage();
  context.setDefaultNavigationTimeout(1);
  const res = page.goto('https://maps.google.com');

  sleep(10);
  browser.close();
}

PW script:

// @ts-check
const { test, chromium } = require('@playwright/test');

test.describe('Editing', () => {
  test('Type login creds', async () => {
    const browser = await chromium.launch({ headless: false, slowMo: 500 });
    const ctx = await browser.newContext();
    const page = await ctx.newPage();
    ctx.setDefaultNavigationTimeout(1);
    await page.goto('https://maps.google.com');

    await new Promise(resolve => setTimeout(resolve, 10000));

    await browser.close();
  });
});
@ankur22 ankur22 added the bug Something isn't working label Jul 7, 2022
@inancgumus inancgumus added the playwright Issue relating to Playwright compatibility label Feb 28, 2023
@inancgumus inancgumus added the next Might be eligible for the next planning (not guaranteed!) label Nov 30, 2023
@ankur22
Copy link
Collaborator Author

ankur22 commented Dec 5, 2023

This issue was fixed with #1035. I've tested the changes with the latest version of main (86329fb) and the following script and the test times out as expected, unlike the previous behaviour where it didn't time out:

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

export const options = {
  scenarios: {
    ui: {
      executor: 'shared-iterations',
      iterations: 1,
      options: {
        browser: {
          type: 'chromium'
        },
      },
    },
  },
}

export default async function () {
  const page = browser.newPage();
  const context = browser.context();
  context.setDefaultNavigationTimeout(1);

  page.goto('https://maps.google.com');

  page.close();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working next Might be eligible for the next planning (not guaranteed!) playwright Issue relating to Playwright compatibility
Projects
None yet
Development

No branches or pull requests

2 participants