英文:
How can I log JavaScript errors from Puppeteer-Sharp?
问题
I have a C# app that uses Puppeteer-Sharp to convert HTML pages to PDF. Everything works great except for one issue. I have a fieldset within which a JavaScript file is used to move checkboxes from the right of the question to the left. When I view the original HTML, the checkboxes have been moved, but in the PDF they are still on the right side. I would like to find out what is going wrong, but I don't know how to get Puppeteer-Sharp to output any error information.
I found this question/answer, which sounds like it is the solution, but I'm not sure what the person actually did or how to make use of it.
How do I get readable browser/page errors out of puppeteer-sharp?
英文:
I have a C# app that uses Puppeteer-Sharp to convert HTML pages to PDF. Everything works great except for one issue. I have a fieldset within which a JavaScript file is used to move checkboxes from the right of the question to the left. When I view the original HTML, the checkboxes have been moved, but in the PDF they are still on the right side. I would like to find out what is going wrong, but I don't know how to get Puppeteer-Sharp to output any error information.
I found this question/answer, which sounds like it is the solution, but I'm not sure what the person actually did or how to make use of it.
How do I get readable browser/page errors out of puppeteer-sharp?
答案1
得分: 1
以下是已翻译的内容:
最好的我找到的是这个,来自 hardkoded/puppeteer-sharp 在 GitHub 上的问题:
var page = await browser.NewPageAsync();
page.PageError += (sender, eventArgs) =>
{
Console.WriteLine("Error Found:");
Console.WriteLine($" {eventArgs.Message}");
};
英文:
The best I could find was this, from an issue on hardkoded/puppeteer-sharp on github:
var page = await browser.NewPageAsync();
page.PageError += (sender, eventArgs) =>
{
Console.WriteLine("Error Found:");
Console.WriteLine($" {eventArgs.Message}");
};
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论