My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
FAQ  
Frequently Asked Questions
Featured
Updated Apr 24, 2012 by ariya.hi...@gmail.com

Q: Why there is no binary package or installer for <insert your favorite OS>?

A: Binary packages, executables, and installer are provided on a voluntary basis. They may appear later, or they may not exist at all. We are a very small team and we can't afford to produce all possible combinations of packages for the different platforms and operating systems out there.

Q: Why does building PhantomJS take a long time?

A: Because PhantomJS build workflow bundles the WebKit module, it needs to compile thousands of source files. Using the binary package is highly recommended. It is fast to download and easy to install.

Q: Why do I get build failure with PhantomJS 1.5 after successfully compiled 1.4?

A: PhantomJS has a completely different build workflow in version 1.5 compared to its previous versions (read the details). If the working directory still has some left-over from 1.4 build process, there will be a compile error, such as:

phantom.cpp:305: error: no matching function for call to 'QWebFrame::evaluateJavaScript(QString, QString)

The solution is to completely clean the directory from old build files. The recommended way is to run git clean -xfd from the top-level. Warning: this will remove everything not stored in the Git repository database (read Git documentation for more info). Please back-up any files appropriately.

After that, run the build script again.

Q: Why do I get the error message phantomjs: cannot connect to X server?

A: In PhantomJS 1.4 or earlier, X server is still needed. The workaround is to use use Xvfb. Starting with PhantomJS 1.5, it is pure headless and there is no need to run X11/Xvfb anymore.

Q: Which WebKit version is used by PhantomJS?

A: If you want to know HTML5/CSS3/other features supported by PhantomJS, using WebKit version is not a good idea. See Supported Features wiki page for details.

If you really like to get the WebKit version, find it via the user agent, run the examples/useragent.js. The actual version depends on the libraries with which PhantomJS was compiled.

Q: Why is PhantomJS not written as Node.js module?

A: The short answer: "No one can serve two masters."

A longer explanation is as follows.

As of now, it is technically very challenging to do so.

Every Node.js module is essentially "a slave" to the core of Node.js, i.e. "the master". In its current state, PhantomJS (and its included WebKit) needs to have the full control (in a synchronous matter) over everything: event loop, network stack, and JavaScript execution.

If the intention is just about using PhantomJS right from a script running within Node.js, such a "loose binding" can be achieved by launching a PhantomJS process and interact with it.

Q: When using render(), why is the background transparent?

A: PhantomJS does not set the background color of the web page at all, it is left to the page to decide its background color. If the page does not set anything, then it remains transparent.

To set an initial background color for a web page, use the following trick:

page.evaluate(function() {
    document.body.bgColor = 'white';
});

Q: What is the difference between PhantomJS (C++) and PyPhantomJS (Python)?

A: They are two different implementations of the same concept. PyPhantomJS supports all features from PhantomJS. It does however have plugin support which allows you to add new functionalities by writing a plugin in Python.

If you only want to use PhantomJS (C++), then no need to have Python installed.

Note: The author of PyPhantomJS can no longer maintain the program. If you want to take over the project, feel free to send the author an email (email is in every source files header), so he can point links to your project fork, and give you control of the PyPi project page.

Q: How do I make a plugin for PyPhantomJS?

A: This wiki article explains how.

Q: I got the error Can't find variable: WebPage. What should I do?

A: You use PhantomJS 1.1 to run examples for version 1.2 (or later). Get a new version of PhantomJS to solve the problem.

Q: Why is the rasterized output is only 8-bit PNG?

A: If you use Xvfb, make sure that it runs in 24-bit mode. See the complete Xvfb instruction steps.

Q: I can't use QtWebKit. Any other solution?

A: Technically it is easy to create something similar using WebKit for Cocoa on Mac OS X. This will give you the best native implementation, if you only care about Mac OS X.

Q: I don't want to use QtWebKit. Any other solution?

A: See above. But think about it, WebKit is LGPL anyway, just like Qt.

Q: Can you add a new API function to do something?

A: If it is reasonable, why not? Please file it as new issue.

Comment by the.wels...@gmail.com, Jan 23, 2011

Would integration to webdriver/selenium 2 be on the table?

This would be brilliant for automated integration testing of web apps....

Comment by m.schwar...@gtempaccount.com, Jan 25, 2011

+ 1 for selenium integration

Comment by johnplus...@gmail.com, Jan 26, 2011

I don't understand the role of phatomjs in an integration with Selenium, do you care to educate me?

Thanks in advance.

Comment by tjpal...@gmail.com, Mar 16, 2011

Does WebGL work?

Comment by paolo.nu...@gmail.com, Mar 23, 2011

>I don't understand the role of phatomjs in an integration with Selenium, do you care to educate me?

Actually, the Ruby testing community in particular is pretty excited about PhantomJS. We're used to write acceptance tests that interact with a real browser, but this tends to be a slow and fragile approach. People have been looking for a headless browser, but the alternatives tend to be clumsy, and not cross-platform enough for some of us. PhantomJS looks like the cross-platform headless browser complete with JS support we've been waiting for. It would be the missing link to have Cucumber applications that can easily test webapps.

To integrate with Selenium, Capybara, or any other testing framework, we'd need a PhantomJS "server" that receives JS commands and stays open until you explicitly close it. As a first step:

- PhantomJS stays open when you launch it without an explicit script. - You can send JavaScript? commands to PhantomJS over a socket.

We already have the exit() function, so that would be fine to close the server.

I can start writing a Capybara driver the moment this is out.

If this makes sense to you, I can open an issue.

Powered by Google Project Hosting