Selenium webdriver works but slow (Java)

I'm using selenium webdriver to capture screenshots of web pages It works well. However, the time from when I run in eclipse to when the screenshot is displayed on the local drive is 7-10 seconds Most of the delay seems to be the launch of 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 any way to save and open a new browser using an already open Firefox browser? Is this code a little heavy?

Details: both CentOS box and win7 box use eclipse myspeedtest. Net displays 22mbps down and 1 Mbps up

Solution

What you requested (allowing webdriver to attach to a running browser) has now become an issue for almost 3 years So far, this feature has not been added As far as I know, there is no way to make Firefox load faster You can try some other techniques

fp.setPreference("webdriver.load.strategy","unstable")

Warning referencing this page:

You can also try loading with a profile to see if it helps

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>