page.waitForNavigation returns null when interceptors are enabled
See original GitHub issueimport 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:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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 becamerequest.url()
method. Full list of changes could be found here: https://github.com/GoogleChrome/puppeteer/releases/tag/v1.0.0Not a general one; you can try caching the page or disabling javascript though.