OAuth2.0 support with k6 browser


I’m wondering if k6 has support for OAuth authentication with browser based tests. Trying to do a proof of concept with twitter’s site signing in with a google account and the execution seems to stop working

Hi @brandonc,

Yes, it should be able to follow the OAuth path. Have you scripted a test to see whether you run into any issues. Can you share it with us as well as the output when the test completes/fails?


Hey @ankur, thanks for your response. I’ve posted my default testing function below. Some issues I ran into are:

  • I’m trying to test google authentication on the twitter site. The button to sign in is an iframe, does k6 browser support interactions with iframes?
  • When browsing the webpage normally, clicking on this button redirects to a separate page for google to handle the authentication. Does k6 browser currently support opening new windows?

When running the test script below, it generates an Uncaught (in promise) error: clicking on "iframe[title=\"Sign in with Google Button\"]": checking hit target: another element is intercepting with pointer action

Any insight on this issue would be greatly appreciated!

export default async function () {
  const browser = chromium.launch({ headless: false });
  const context = browser.newContext();
  const page = context.newPage();

  const loginModal = 'div[aria-labelledby="modal-header"]';

  try {
    await page.goto("https://twitter.com", { waitUntil: "networkidle" });


    page.locator(loginModal).waitFor({ state: "visible" });

    check(page, {
      "login modal is visible": page.locator(loginModal).isVisible(),

    page.locator('iframe[title="Sign in with Google Button"]').click();
  } finally {

Hi @brandonc,

Aha, now i understand the issue. So you’ve hit upon two things that k6-browser doesn’t support:

  1. k6-browser doesn’t support iframe yet. You could try a workaround using page.evaluate, here’s a post that might help you: Locating elements within an iframe.
  2. Clicking on a button/link that opens a new window/page/tab is supported, but there’s a known issue which you can track of the issue by following along here.

Hope this helps a little bit,