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.

firefox: page.url() does not show url fragments.

See original GitHub issue

Steps to reproduce

Tell us about your environment:

What steps will reproduce the problem?

Please include code that reproduces the issue. (As pointed out by @andersk here.)

const puppeteer = require("puppeteer");
(async () => {
  const browser = await puppeteer.launch({ headless: false, slowMo: 200, product: "firefox" });
  const page = await browser.newPage();
  await page.goto("https://en.wikipedia.org/wiki/Puppeteer");
  await page.waitForSelector("a[href='#References']", { visible: true });
  await Promise.all([
    page.waitForNavigation(),
    page.click("a[href='#References']"),
  ]);
  console.log(page.url());
  await browser.close();
})();

What is the expected result? page.url() should show fragment URL. For eg: https://en.wikipedia.org/wiki/Puppeteer/#References (When we run with chrome)

What happens instead? page.url() does not show URL with fragment.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
whimboocommented, Jun 24, 2022

This works with Firefox 103 Nightly. So it has been fixed at some point:

  puppeteer:protocol:RECV ◀   '{"method":"Page.navigatedWithinDocument","params":{"frameId":"32","url":"https://en.wikipedia.org/wiki/Puppeteer#References"},"sessionId":"8c9b8a9f-d0c1-4657-83df-5d22744f6685"}'
1reaction
anderskcommented, Jan 28, 2021

Hmm, there is a real problem with fragment links though. This works with Chromium but times out with Firefox:

const puppeteer = require("puppeteer");
(async () => {
  const browser = await puppeteer.launch({ headless: false, slowMo: 200, product: "firefox" });
  const page = await browser.newPage();
  await page.goto("https://en.wikipedia.org/wiki/Puppeteer");
  await page.waitForSelector("a[href='#References']", { visible: true });
  await Promise.all([
    page.waitForNavigation(),
    page.click("a[href='#References']"),
  ]);
  console.log(page.url());
  await browser.close();
})();
Read more comments on GitHub >

github_iconTop Results From Across the Web

Match a Fragment identifier in a URL - Mozilla Discourse
One thing you could do is not display the page based on its current fragment identifier. There are several ways to achieve that,...
Read more >
Firefox: page does not reload if i select the address bar and ...
If you've got fragments within your URL, Firefox won't refresh but will simply try and take you to the location of the ID...
Read more >
Boldly link where no one has linked before: Text Fragments
Text Fragments let you specify a text snippet in the URL fragment. When navigating to a URL with such a text fragment, the...
Read more >
URI fragment - Wikipedia
The fragment identifier introduced by a hash mark # is the optional last part of a URL for a document. It is typically...
Read more >
6 Things You Should Know About Fragment URLs
If you try using fragment URLs in an HTTP sniffer like HttpWatch, you'll never see the fragment IDs in the requested URL or...
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