Selenium WebDriver works but SLOW (Java)

0
0

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.

  • You must to post comments
0
0

What you are asking for (allowing WebDriver to 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.

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

Quoting the caveat from this page:

There is beta feature to make firefox not wait for the full page to
load after calling .get or .click. This may cause immediate find’s to
break, so please be sure to use an implicit or explicit wait too. This
is only available for Firefox and not other browsers.

You can also try loading with a profile and see if that helps at all.

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website