I am using Selenium WebDriver to take a screenshot of webpages. It runs great. However, from the time I hit run in eclipse to the time the screenshot shows up in my local drive is 7-10 seconds. Most of the latency seems to be launching Firefox.
Code:
WebDriver driver = new FirefoxDriver();
driver.get("http://www.cnn.com");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\test\\screenshot.png"));
How can I speed up this process? Is there a way that I can use an already opened Firefox browser to save on opening a new one? Is this code somehow heavy?
Details: Tried on CentOS box and Win7 box both using eclipse. myspeedtest.net shows 22Mbps down and 1 Mbps up.
What you are asking for (allowing
WebDriverto attach to a running browser) has been an issue now for almost 3 years. To date, this feature has still not been added. As far as I am aware, there is no way to make Firefox load any faster. You can try a few other tricks though.Quoting the caveat from this page:
You can also try loading with a profile and see if that helps at all.