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
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
add a comment |
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
In yourpage.gotoline, 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.screenshotis not working for me. The browser opens and navigates to the file (I checked it in headful mode), but it is actually stuck whenpage.screenshotis called.
– Thomas Dondorf
Mar 7 at 19:52
add a comment |
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
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
firefox
edited Mar 7 at 19:28
tremby
asked Mar 7 at 4:25
trembytremby
4,68523554
4,68523554
In yourpage.gotoline, 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.screenshotis not working for me. The browser opens and navigates to the file (I checked it in headful mode), but it is actually stuck whenpage.screenshotis called.
– Thomas Dondorf
Mar 7 at 19:52
add a comment |
In yourpage.gotoline, 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.screenshotis not working for me. The browser opens and navigates to the file (I checked it in headful mode), but it is actually stuck whenpage.screenshotis 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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
In your
page.gotoline, 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.screenshotis not working for me. The browser opens and navigates to the file (I checked it in headful mode), but it is actually stuck whenpage.screenshotis called.– Thomas Dondorf
Mar 7 at 19:52