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

Fix NPD when using goto on a second page #1301

Merged
merged 1 commit into from
May 7, 2024
Merged

Fix NPD when using goto on a second page #1301

merged 1 commit into from
May 7, 2024

Conversation

ankur22
Copy link
Collaborator

@ankur22 ankur22 commented May 3, 2024

What?

This fixes an issue when working with a second tab (i.e. opening a new page in the same existing browserContext), and navigating to a url.

You can also test with the following test script to see what happens without the fix and with the fix:

import { browser } from "k6/x/browser";

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

export default async function () {
  const page = browser.newPage();
  await page.goto("https://k6.io", { waitUntil: "networkidle" });

  const context = browser.context();
  const page2 = context.newPage();
  await page2.goto("https://k6.io", { waitUntil: "networkidle" });

  page.close();
}

Why?

This issue would arise as soon as any API is used from the new page instance. This was occurring due to the unmapped browserContext when getting it from the browser.

Checklist

  • I have performed a self-review of my code
  • I have added tests for my changes
  • I have commented on my code, particularly in hard-to-understand areas

Related PR(s)/Issue(s)

This fixes an issue when working with a second tab (i.e. opening a new
page in the same existing browserContext), and navigating to a url. In
fact this issue would arise as soon as any API is used from the new
page instance. This was occurring due to the unmapped browserContext
when getting it from the browser.
@ankur22 ankur22 merged commit 991c699 into main May 7, 2024
17 checks passed
@ankur22 ankur22 deleted the fix/new-tab-goto branch May 7, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants