TestingBot Blog

TestingBot provides a cloud of browsers to run Automated, Live and Visual browser testing.

< Back to Blog Overview

PhantomJS Selenium testing in the cloud



Next to the +300 browser combinations we support we've now added support for PhantomJS.

PhantomJS allows for headless testing of your websites. It is very fast compared to normal browsers, because it doesn't draw anything to the screen, does not require a desktop environment or any other slow components. Since it's so fast, it's perfect to use as a first test-run, before doing tests on real browsers.

We're running each PhantomJS instance in its own Docker container, providing a pristine test environment for each test, guaranteeing security and speed.

Run a PhantomJS Webdriver Test

To get started, all you need to do is have your Selenium test point to our grid and specify these desired capabilities:

capabilities = {
"browserName" : "phantomjs",
"platform" : "LINUX"

Below is an example in Ruby:

#!/usr/bin/env ruby

require 'rubygems'
require 'selenium-webdriver'

caps = {
:browserName => "phantomjs",
:platform => "LINUX"

driver = Selenium::WebDriver.for(
:url => "http://key:secret@hub.testingbot.com:4444/wd/hub",
:desired_capabilities => caps)
driver.navigate.to "http://www.google.com"
element = driver.find_element(:name, 'q')
element.send_keys "TestingBot"
puts driver.title

This code example will run a PhantomJS test on our Selenium grid and finish in less than 3 seconds.
PhantomJS does support taking screenshots, a video of the session however is not possible.

With our selenium grid, we can provide you access to hundreds of PhantomJS instances to use simultaneously.

Sign up for free at TestingBot and run your first PhantomJS test in a matter of minutes.

< Back to Blog Overview