Can PhantomJS take screenshots?

Can PhantomJS take screenshots?

15.07.13

Many people think that PhantomJS (as a headless browser) cannot take screenshots.

This is not true!

According to PhantomJS documentation, it can take screenshots.

Let’s try to do that.

import static com.codeborne.selenide.Selenide.*;

public class TestPhantomScreenshot {
  public static void main(String[] args) {
    System.setProperty("browser", "phantomjs");
    open("http://google.com");
    screenshot("google-com-screenshot");
    close();
  }
}

It works!

Though, it does not work ideally. Well, screenshots of google.com, habrahabr.ru and skype.com look good, but screenshot of selenide.org is quite strange.

Does it mean that PhantomJS is not mature enough yet? I don’t know. But at least PhantomJS can do screenshots.

google.com habrahabr.ru skype.com selenide.org

15.07.13