PhantomJS is a headless Webkit-based browser. We can use PhantomJS in conjunction with Selenium WebDriver to run basic functional tests.
In this recipe, we will set up and use PhantomJS to run a simple test.
You will need PhantomJS binary for this example. You can download the appropriate binary from http://phantomjs.org/.
In this example, the Windows version of PhantomJS is used.
You will also need to add a dependency in the maven pom.xml
file, as follows:
<dependency> <groupId>com.github.detro</groupId> <artifactId>phantomjsdriver</artifactId> <version>1.2.0</version> <scope>test</scope> </dependency>