Can PhantomJS take screenshots?

Can PhantomJS take screenshots?

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");

It works!

Though, it does not work ideally. Well, screenshots of, and look good, but screenshot of is quite strange.

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