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.url() does not reflect pushstate-driven updates...

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 0.13.0
  • Platform / OS version: macOS 10.13.2
  • Node.js version: 8.9.4

What steps will reproduce the problem?

i’ve tried a couple of approaches:

await Promise.all([
    page.waitForNavigation(), // also w/ the { waitUntil: 'networkidle2' } option
    page.click(<anchor tag selector>)
]);

// alternately, i've tried:
// await page.click(<anchor tag selector>);
// await page.waitFor(3000);

expect(page.url()).toBe(<expected url>); // fails w/ old url - as though the page never navigated

when i use puppeteer.launch({ headless: false, slowMo: 1000 }); to debug things, i’m able to observe the navigation happening so the page.click() bit seems to be working.

What is the expected result?

assertion shown above succeeds

What happens instead?

assertion shown above fails w/ old url as though the page never navigated

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
aslushnikovcommented, Jan 9, 2018

@busticated yes, the same root issue: Devtools protocol operates in terms of browser navigations and doesn’t take history API into account.

0reactions
busticatedcommented, Jan 9, 2018

@aslushnikov ok but what about page.url()? that was the main point with this issue - it seems to always return whatever the original url was. is this also related to the spotty history api support?

Read more comments on GitHub >

github_iconTop Results From Across the Web

page.url() does not reflect pushstate-driven updates... #1736
i suppose a related but slightly off-topic question is: does page.waitForNavigation() handle pushstate-driven (history api) navigation changes?
Read more >
history.pushState does not update url for "share ..." button on ...
button on the Chrome menu, the old URL (before calling history.pushState) is shared instead. Am I missing anything and how can I fix...
Read more >
history.replaceState() does not refresh :target in Internet Explorer
pushState() in Internet Explorer, the URL gets updated correctly but the actual screen does not get updated to reflect the new URL.
Read more >
Manually setting history state - Hotwire Discussion
Hey! I have an index page which is filterable by typing into a search input. 500ms after the user stopped typing, the app...
Read more >
How to update the browser URL without refreshing the page ...
pushState() method can be used to push a new entry into the browser's history—and as a result, update the displayed URL—without refreshing ...
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