Opening a local file with local references with puppeteer-firefoxOpening local html file using puppeteerTargeting only Firefox with CSSHow do I redirect a browser to a local file in ASP.NET?How do I manually fire HTTP POST requests with Firefox or Chrome?Can I open a local file, in Firefox, with a link link like: file:///home/userChanging shown URL with a firefox addonHow do I allow pop-ups from local files (file:/// addresses) in Firefox 5?Loading and using a JS module in puppeteerOpening local html file using puppeteerPuppeteer authentication does not work in headless mode but yes in non headless modeHow to download HTML, CSS, and IMGs using Puppeteer and JSDOM

Shouldn’t conservatives embrace universal basic income?

What would sports be like in a dystopia?

How can ping know if my host is down

Why is the Sun approximated as a black body at ~ 5800 K?

How can I write humor as character trait?

How to convince somebody that he is fit for something else, but not this job?

How to make money from a browser who sees 5 seconds into the future of any web page?

Why Shazam when there is already Superman?

A Trivial Diagnosis

Has any country ever had 2 former presidents in jail simultaneously?

Did the UK lift the requirement for registering SIM cards?

A variation to the phrase "hanging over my shoulders"

Review your own paper in Mathematics

The IT department bottlenecks progress, how should I handle this?

Which Article Helped Get Rid of Technobabble in RPGs?

Can I turn my anal-retentiveness into a career?

Is a Java collection guaranteed to be in a valid, usable state after a ConcurrentModificationException?

Non-trope happy ending?

Why can't the Brexit deadlock in the UK parliament be solved with a plurality vote?

C++ copy constructor called at return

Is it necessary to use pronouns with the verb "essere"?

How to explain what's wrong with this application of the chain rule?

Find the next value of this number series

Doesn't the system of the Supreme Court oppose justice?



Opening a local file with local references with puppeteer-firefox


Opening local html file using puppeteerTargeting only Firefox with CSSHow do I redirect a browser to a local file in ASP.NET?How do I manually fire HTTP POST requests with Firefox or Chrome?Can I open a local file, in Firefox, with a link link like: file:///home/userChanging shown URL with a firefox addonHow do I allow pop-ups from local files (file:/// addresses) in Firefox 5?Loading and using a JS module in puppeteerOpening local html file using puppeteerPuppeteer authentication does not work in headless mode but yes in non headless modeHow to download HTML, CSS, and IMGs using Puppeteer and JSDOM













2















This is a similar question to Opening local html file using puppeteer, except that that one is using regular Puppeteer (headless Chrome) and this one is using the Firefox version, and I care about references to other local files.



I'm trying to open a local HTML file with puppeteer-firefox. Here's some example code:



const pptrFirefox = require('puppeteer-firefox');
const path = require('path');

(async () =>
const browser = await pptrFirefox.launch();
const page = await browser.newPage();
await page.goto(`file:$path.join(__dirname, 'template.html')`);
await page.screenshot(path: 'example.png');
await browser.close();
)();


This hangs at the page.screenshot line.



I've tried this with file: and file:// as the prefix of the path. It's the same either way.



It works fine if the URL is something remote like https://example.com instead.



My first idea for a workaround was to get a string of the HTML I want, by using a templating library or just readFile, and then passing this to page.setContent. This works, but then the page won't load its assets such as relative paths to local image files. I've tried prefixing those asset paths with the full file: path; no difference.



I swapped out puppeteer-firefox for the regular puppeteer, and it works.



Will headless Firefox simply refuse to load local files? Or am I doing something wrong? Or is there a bug in puppeteer-firefox?










share|improve this question
























  • In your page.goto line, you are missing a closing bracket }. Apart from that, your code is working fine for me (Windows).

    – Thomas Dondorf
    Mar 7 at 18:26











  • I think my comment got missing :/ That feature is still failing in Firefox, see github.com/GoogleChrome/puppeteer/blob/…, You'll have to wait for it.

    – hardkoded
    Mar 7 at 18:52











  • @ThomasDondorf that was a typo for my example code which doesn't exist in my application; sorry about that. You say it's working for you on Windows? You're definitely using the Firefox version of puppeteer?

    – tremby
    Mar 7 at 19:29











  • @hardkoded: I don't fully understand the code you linked. Are you saying the feature isn't complete yet? I expected to see something on aslushnikov.github.io/ispuppeteerfirefoxready but I don't see where this feature would be.

    – tremby
    Mar 7 at 19:31











  • @tremby Sorry, I was wrong. page.screenshot is not working for me. The browser opens and navigates to the file (I checked it in headful mode), but it is actually stuck when page.screenshot is called.

    – Thomas Dondorf
    Mar 7 at 19:52















2















This is a similar question to Opening local html file using puppeteer, except that that one is using regular Puppeteer (headless Chrome) and this one is using the Firefox version, and I care about references to other local files.



I'm trying to open a local HTML file with puppeteer-firefox. Here's some example code:



const pptrFirefox = require('puppeteer-firefox');
const path = require('path');

(async () =>
const browser = await pptrFirefox.launch();
const page = await browser.newPage();
await page.goto(`file:$path.join(__dirname, 'template.html')`);
await page.screenshot(path: 'example.png');
await browser.close();
)();


This hangs at the page.screenshot line.



I've tried this with file: and file:// as the prefix of the path. It's the same either way.



It works fine if the URL is something remote like https://example.com instead.



My first idea for a workaround was to get a string of the HTML I want, by using a templating library or just readFile, and then passing this to page.setContent. This works, but then the page won't load its assets such as relative paths to local image files. I've tried prefixing those asset paths with the full file: path; no difference.



I swapped out puppeteer-firefox for the regular puppeteer, and it works.



Will headless Firefox simply refuse to load local files? Or am I doing something wrong? Or is there a bug in puppeteer-firefox?










share|improve this question
























  • In your page.goto line, you are missing a closing bracket }. Apart from that, your code is working fine for me (Windows).

    – Thomas Dondorf
    Mar 7 at 18:26











  • I think my comment got missing :/ That feature is still failing in Firefox, see github.com/GoogleChrome/puppeteer/blob/…, You'll have to wait for it.

    – hardkoded
    Mar 7 at 18:52











  • @ThomasDondorf that was a typo for my example code which doesn't exist in my application; sorry about that. You say it's working for you on Windows? You're definitely using the Firefox version of puppeteer?

    – tremby
    Mar 7 at 19:29











  • @hardkoded: I don't fully understand the code you linked. Are you saying the feature isn't complete yet? I expected to see something on aslushnikov.github.io/ispuppeteerfirefoxready but I don't see where this feature would be.

    – tremby
    Mar 7 at 19:31











  • @tremby Sorry, I was wrong. page.screenshot is not working for me. The browser opens and navigates to the file (I checked it in headful mode), but it is actually stuck when page.screenshot is called.

    – Thomas Dondorf
    Mar 7 at 19:52













2












2








2








This is a similar question to Opening local html file using puppeteer, except that that one is using regular Puppeteer (headless Chrome) and this one is using the Firefox version, and I care about references to other local files.



I'm trying to open a local HTML file with puppeteer-firefox. Here's some example code:



const pptrFirefox = require('puppeteer-firefox');
const path = require('path');

(async () =>
const browser = await pptrFirefox.launch();
const page = await browser.newPage();
await page.goto(`file:$path.join(__dirname, 'template.html')`);
await page.screenshot(path: 'example.png');
await browser.close();
)();


This hangs at the page.screenshot line.



I've tried this with file: and file:// as the prefix of the path. It's the same either way.



It works fine if the URL is something remote like https://example.com instead.



My first idea for a workaround was to get a string of the HTML I want, by using a templating library or just readFile, and then passing this to page.setContent. This works, but then the page won't load its assets such as relative paths to local image files. I've tried prefixing those asset paths with the full file: path; no difference.



I swapped out puppeteer-firefox for the regular puppeteer, and it works.



Will headless Firefox simply refuse to load local files? Or am I doing something wrong? Or is there a bug in puppeteer-firefox?










share|improve this question
















This is a similar question to Opening local html file using puppeteer, except that that one is using regular Puppeteer (headless Chrome) and this one is using the Firefox version, and I care about references to other local files.



I'm trying to open a local HTML file with puppeteer-firefox. Here's some example code:



const pptrFirefox = require('puppeteer-firefox');
const path = require('path');

(async () =>
const browser = await pptrFirefox.launch();
const page = await browser.newPage();
await page.goto(`file:$path.join(__dirname, 'template.html')`);
await page.screenshot(path: 'example.png');
await browser.close();
)();


This hangs at the page.screenshot line.



I've tried this with file: and file:// as the prefix of the path. It's the same either way.



It works fine if the URL is something remote like https://example.com instead.



My first idea for a workaround was to get a string of the HTML I want, by using a templating library or just readFile, and then passing this to page.setContent. This works, but then the page won't load its assets such as relative paths to local image files. I've tried prefixing those asset paths with the full file: path; no difference.



I swapped out puppeteer-firefox for the regular puppeteer, and it works.



Will headless Firefox simply refuse to load local files? Or am I doing something wrong? Or is there a bug in puppeteer-firefox?







firefox puppeteer firefox-headless






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 19:28







tremby

















asked Mar 7 at 4:25









trembytremby

4,68523554




4,68523554












  • In your page.goto line, you are missing a closing bracket }. Apart from that, your code is working fine for me (Windows).

    – Thomas Dondorf
    Mar 7 at 18:26











  • I think my comment got missing :/ That feature is still failing in Firefox, see github.com/GoogleChrome/puppeteer/blob/…, You'll have to wait for it.

    – hardkoded
    Mar 7 at 18:52











  • @ThomasDondorf that was a typo for my example code which doesn't exist in my application; sorry about that. You say it's working for you on Windows? You're definitely using the Firefox version of puppeteer?

    – tremby
    Mar 7 at 19:29











  • @hardkoded: I don't fully understand the code you linked. Are you saying the feature isn't complete yet? I expected to see something on aslushnikov.github.io/ispuppeteerfirefoxready but I don't see where this feature would be.

    – tremby
    Mar 7 at 19:31











  • @tremby Sorry, I was wrong. page.screenshot is not working for me. The browser opens and navigates to the file (I checked it in headful mode), but it is actually stuck when page.screenshot is called.

    – Thomas Dondorf
    Mar 7 at 19:52

















  • In your page.goto line, you are missing a closing bracket }. Apart from that, your code is working fine for me (Windows).

    – Thomas Dondorf
    Mar 7 at 18:26











  • I think my comment got missing :/ That feature is still failing in Firefox, see github.com/GoogleChrome/puppeteer/blob/…, You'll have to wait for it.

    – hardkoded
    Mar 7 at 18:52











  • @ThomasDondorf that was a typo for my example code which doesn't exist in my application; sorry about that. You say it's working for you on Windows? You're definitely using the Firefox version of puppeteer?

    – tremby
    Mar 7 at 19:29











  • @hardkoded: I don't fully understand the code you linked. Are you saying the feature isn't complete yet? I expected to see something on aslushnikov.github.io/ispuppeteerfirefoxready but I don't see where this feature would be.

    – tremby
    Mar 7 at 19:31











  • @tremby Sorry, I was wrong. page.screenshot is not working for me. The browser opens and navigates to the file (I checked it in headful mode), but it is actually stuck when page.screenshot is called.

    – Thomas Dondorf
    Mar 7 at 19:52
















In your page.goto line, you are missing a closing bracket }. Apart from that, your code is working fine for me (Windows).

– Thomas Dondorf
Mar 7 at 18:26





In your page.goto line, you are missing a closing bracket }. Apart from that, your code is working fine for me (Windows).

– Thomas Dondorf
Mar 7 at 18:26













I think my comment got missing :/ That feature is still failing in Firefox, see github.com/GoogleChrome/puppeteer/blob/…, You'll have to wait for it.

– hardkoded
Mar 7 at 18:52





I think my comment got missing :/ That feature is still failing in Firefox, see github.com/GoogleChrome/puppeteer/blob/…, You'll have to wait for it.

– hardkoded
Mar 7 at 18:52













@ThomasDondorf that was a typo for my example code which doesn't exist in my application; sorry about that. You say it's working for you on Windows? You're definitely using the Firefox version of puppeteer?

– tremby
Mar 7 at 19:29





@ThomasDondorf that was a typo for my example code which doesn't exist in my application; sorry about that. You say it's working for you on Windows? You're definitely using the Firefox version of puppeteer?

– tremby
Mar 7 at 19:29













@hardkoded: I don't fully understand the code you linked. Are you saying the feature isn't complete yet? I expected to see something on aslushnikov.github.io/ispuppeteerfirefoxready but I don't see where this feature would be.

– tremby
Mar 7 at 19:31





@hardkoded: I don't fully understand the code you linked. Are you saying the feature isn't complete yet? I expected to see something on aslushnikov.github.io/ispuppeteerfirefoxready but I don't see where this feature would be.

– tremby
Mar 7 at 19:31













@tremby Sorry, I was wrong. page.screenshot is not working for me. The browser opens and navigates to the file (I checked it in headful mode), but it is actually stuck when page.screenshot is called.

– Thomas Dondorf
Mar 7 at 19:52





@tremby Sorry, I was wrong. page.screenshot is not working for me. The browser opens and navigates to the file (I checked it in headful mode), but it is actually stuck when page.screenshot is called.

– Thomas Dondorf
Mar 7 at 19:52












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036091%2fopening-a-local-file-with-local-references-with-puppeteer-firefox%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036091%2fopening-a-local-file-with-local-references-with-puppeteer-firefox%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович