Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

page.waitForNavigation causes time out #226

@inancgumus

Description

@inancgumus

Please see grafana/k6#4469 and grafana/k6#4469 for details.

Adding page.waitForNavigation(); in place of page.waitForSelector('div.cb-content'); caused a waitForFrameNavigation timed out after 30s.

Script Source
import launcher from 'k6/x/browser';
import { group, sleep } from 'k6';

export default function () {
  const browser = launcher.launch('chromium', {
    headless: false,
  });

  const context = browser.newContext({
  });

  const page = context.newPage();

  group("Navigate to Homepage", () => {
    page.goto('https://trollflix.com'); // without the below waitForSelector, the page.$$ expression returns a length of 0

    page.waitForSelector('div.cb-content'); // required here even if I were to use waitUntil: 'networkidle' above
    
    // grab the number of displayed videos (should be 12)
    const videoCount = page.$$('div.cb-content').length;
    console.log(`Found ${videoCount} in page`);
  });

  sleep(2);

  group("Filter by Gaming", () => {
    page.hover('#hn-categories');

    sleep(1);

    // without the below waitForSelector, the page.$$ expression returns a length of 0 (interestingly, not the previous value - 12 - so the expression was evaluated after the page partially refreshed)
    page.$('//div[text()="Gaming"]').click(); 

    page.waitForSelector('div.cb-content'); // waiting for the div here ensures the videoCount updates as expected

    // grab the number of displayed videos (should be 2)
    const videoCount = page.$$('div.cb-content').length;
    console.log(`Found ${videoCount} in page`);
  });
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions