如何使用C#从已打开的'firefox'Web浏览器中获取整页屏幕截图 [英] How to take full page screen shot from an already opened 'firefox' web browser, using C#
问题描述
我需要从Firefox浏览器中将FULL WEB PAGE作为IMAGE。有没有其他解决方法,请指教。
谢谢。
我试过的:
我试过'SHDocVw.dll'样本,但它只适用于IE。
现在我刚开始尝试使用DdeClient。直到,我只能获取URL。
Hi,
I need to take FULL WEB PAGE as an IMAGE from Firefox browser. Is there any other workaround, please advise.
Thanks.
What I have tried:
I have tried 'SHDocVw.dll' samples, but it works with IE only.
Now i am just now started trying with DdeClient. Till, i can get the URL only.
推荐答案
如果您是通过代码执行此操作,则需要使用Selenium WebDriver [ ^ ]:
If you're doing this through code, you'll want to use the Selenium WebDriver[^]:
IWebDriver driver = new FirefoxDriver();
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl(url);
ITakesScreenshot screenshotDriver = driver as ITakesScreenshot;
Screenshot screenshot = screenshotDriver.GetScreenshot();
screenshot.SaveAsFile(@"c:\test.png", ImageFormat.Png);
Selenium WebDriver C#完整网站截图使用ChromeDriver和FirefoxDriver - Stack Overflow [ ^ ]
WebDriver - 目录 [ ^ ]
这意味着您需要从新的Firefox实例中截取屏幕截图,如这不可行o附加到现有实例 [ ^ ]。
如果你想手动完成,那就有一个全力以赴页面截图按钮在开发人员工具中。
Selenium WebDriver C# Full Website Screenshots With ChromeDriver and FirefoxDriver - Stack Overflow[^]
WebDriver - Table of Content[^]
That does mean you'll need to take the screenshot from a new instance of Firefox, as it's not feasible to attach to an existing instance[^].
If you want to do it manually, there's a "Take a full page screenshot" button in the developer tools.
参见搜索 - CodeProject [ ^ ]。
通常,您需要打开浏览器窗口到页面,截取屏幕截图,向浏览器窗口发送消息以将其向下滚动,拍摄另一个屏幕截图,滚动,...然后将图像拼接在一起。我知道FireFox没有自动化界面可以让这更容易,我没有任何例子。
Generically, you need to open the browser window to the page, take a screenshot, send messages to the browser window to scroll it down, take another screenshot, scroll, ... then stitch the images together. I know of no automation interface for FireFox to make this easier and I don't have any examples.
这篇关于如何使用C#从已打开的'firefox'Web浏览器中获取整页屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!