question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

page.waitForNavigation returns null when interceptors are enabled

See original GitHub issue
import puppeteer from "puppeteer";
import {pause, disableImage} from "../../helpers";
import parseUrl from "parse-url";
import env from './../../env';

let page;
let browser;


beforeAll(async () => {
    browser = await puppeteer.launch({
        slowMo: 80,
        args: [
            `--window-size=${env.width},${env.height}`,
            ...env.args,
        ]
    });
    page = await browser.newPage();
    await page.setRequestInterception(true);
    page.on('request', request => {
        // add stylesheet, font
        if (request.resourceType === 'image')
            request.abort();
        else
            request.continue();
    });
    await page.setViewport({width: env.width, height: env.height});
});


afterAll(() => {
    browser.close();
});


describe("failure-in-login", () => {
    test("should fail due to wrong user", async () => {
        await page.goto(env.host);
        await page.waitForSelector('input#user');
        await pause(100);
        await page.type('input#user', 'admiin');
        await page.type('input#password', env.admin.password);
        const [response] = await Promise.all([
            page.waitForNavigation(),
            page.click('#submit')
        ]);

        expect(parseUrl(response.url).query.user).toEqual('admiin');
    }, 10000 * env.time);
});

I have an error on expect(parseUrl(response.url).query.user).toEqual(‘admiin’); caused by response variable to be null. and if I only remove interceptor things work just fine.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
aslushnikovcommented, Jan 17, 2018

@hasangilak we’ve fixed a few bugs related to this in 1.0.0. Please, try updating.

Beware: all getters in 0.13 became methods in 1.0. For example, request.url getter became request.url() method. Full list of changes could be found here: https://github.com/GoogleChrome/puppeteer/releases/tag/v1.0.0

0reactions
aslushnikovcommented, May 31, 2018

is there any way to drastically reduce test time?

Not a general one; you can try caching the page or disabling javascript though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

page.waitForNavigation returns null when interceptors are ...
import puppeteer from "puppeteer"; import {pause, disableImage} from "../../helpers"; import parseUrl from "parse-url"; import env from './.
Read more >
Clicking navigation button in Puppeteer returns null response ...
I'm trying to test clicking a button on a registration app to make sure that the page correctly navigates to the right page....
Read more >
Puppeteer documentation - DevDocs
Returns null if the browser instance was created with puppeteer.connect method. ... Returns true if the page has JavaScript enabled, false otherwise.
Read more >
Puppeteer API v1.0.0 - CSDN博客
If no element matches the selector, the return value resolve to null . Shortcut for page.mainFrame().$(selector). page.$$(selector).
Read more >
node_modules/puppeteer/lib/types.d.ts - devtools ... - Google Git
The returned object represents the root accessible node of the page. ... Returns `null` if the browser instance was created with.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found