A headless Internet Explorer browser using the .NET WebBrowser Class with a Javascript API running on the V8 engine.

The API is coded as a port of PhantomJS. Perfect for test automation. If you have used phantom before then you already know how to use TrifleJS.

It supports different version of IE interchangeably depending on the current version installed (IE9 can emulate IE7, IE8 or IE9 but not IE10).

C:> TrifleJS.exe --emulate=IE8 --render=http://whatbrowser.org/

IE 8

Command Line Options

TrifleJS runs on the command line, interactively (no arguments) or by opening a *.js file.

C:> TrifleJS.exe --version

Original PhantomJS API Documentation for this section is in:


Feature Status Notes
(no arguments) Ready Runs interactive mode (REPL).
--help or -h Ready Lists command line options and quits.
--version or -v Ready Targetted version of PhantomJS
--ignore-ssl-errors=[true/false] Ignores SSL errors.
--load-images=[true/false] Load all inlined images (default true).
--output-encoding=encoding Encoding for terminal output (default utf8).
--proxy=address:port Ready Specifies the proxy server to use.
--proxy-type=[http/socks5/none] Specifies the type of the proxy server.
--proxy-auth=user:passw Ready Authentication info for the proxy.
--script-encoding=encoding Encoding for starting script (default utf8).
--web-security=[true/false] Prevents cross-domain XHR (default true).
--config=/path/to/config.json JSON replacement for command switches.


Object: phantom

Original PhantomJS API Documentation for this section is in:


Feature Status Notes
.args Ready Arguments passed to the script.
.cookies Get or set Cookies for any domain.
.cookiesEnabled Controls whether cookies are enabled
.version Ready The version of PhantomJS instance.
.libraryPath Ready Used by .injectJs() to find scripts.
.scriptName Ready Name of the invoked script file.
.addCookie({cookie}) Add a Cookie to the CookieJar.
.clearCookies() Delete all Cookies.
.deleteCookie(name) Deletes a Cookie.
.exit(returnValue) Ready Exits program with return value.
.injectJS(filename) Ready Injects external scripts
#onError Errors not caught by a WebPage#onError

Module: WebPage

Original PhantomJS API Documentation for this section is in:


Feature Status Notes
.canGoBack true if browser can navigate back.
.canGoForward true if browser can navigate forward.
.clipRect Page area rasterized during .render()
.content Ready HTML content of the web page.
.cookies Get/set cookies visible in current URL.
.customHeaders Ready Additional HTTP headers sent to server.
.paperSize Size of the page when rendered as PDF.
.plainText Ready Content of the web page in plain text.
.settings Various settings of the web page.
.scrollPosition Scroll position of the web page.
.viewportSize Ready Size of viewport for the layout process.
.url Ready Current URL of the web page.
.title Ready Title of the page.
.windowName Name of the main browser window.
.zoomFactor Ready Scaling factor for rendering pages.
.addCookie({cookie}) Add a cookie to the page.
.clearCookies() Delete all Cookies for current domain.
.close() Ready Closes page to release memory.
.deleteCookie(name) Deletes a Cookie in current domain.
.evaluate(function, arg1, arg2,..) Ready Evaluates function inside current page.
.evaluateAsync(function) evaluate() without blocking execution.
.evaluateJavaScript(str) Ready Evaluates script in current page.
.includeJs(url, callback) Ready Includes script the specified url
.injectJs(filename) Ready Injects script code specified file
.open(url, callback) Ready Opens url and loads it to the page.
.open(url, method, callback) Ready As above but using a HTTP method.
.open(url, method, data, callback) Ready As above, using a HTTP method and data.
.openUrl(url, httpConf, settings) Opens url with specific settings.
.reload() Reloads current page.
.render(filename) Ready Renders page to specified filename
.renderBase64(format) Ready Renders page as Base64-encoded string
#onAlert Ready Fires for alert() calls on page.
#onCallback Ready Fires for window.callPhantom calls.
#onClosing Fires on window.close()
#onConfirm Ready Fires for confirm() calls on page.
#onConsoleMessage Fires for console messages on page.
#onError Partial Stacktrace not implemented yet
#onInitialized Ready Fires after page created and before URL loaded
#onLoadStarted Ready Fires when page starts loading.
#onLoadFinished Ready Fires when page finishes loading.
#onNavigationRequested Fires for all navigations events.
#onPageCreated Fires on child page created – ie window.open().
#onPrompt Ready Fires when prompt() call made on page.
#onResourceRequested Fires for all requests resources (image, css, js etc).
#onResourceCompleted Fires when resources are received.
#onResourceTimeout Fires when resources requested time out.
#onResourceError (v1.9) Fires when error occurs loading resource.
#onUrlChanged Fires whenever URL changes.


Module: System

Original PhantomJS API Documentation for this section is in:


Feature Status Notes
.pid Ready Current Process ID for TrifleJS process.
.platform Ready Name of platform, always phantomjs.
.os Ready Information about the operating system
.env Ready Key-value pairs of environment variables
.args Ready List of the command-line arguments

Module: FileSystem

Original PhantomJS API Documentation for this section is in:


Feature Status Notes
.separator The path separator for O/S.
.workingDirectory The current working directory.
Query Methods
.list(path) Ready Returns list of files in path.
.absolute(path) Ready Returns absolute path to file or directory
.exists(path) Ready true if a file or a directory exists.
.isDirectory(path) Ready true if specified path is directory.
.isFile(path) Ready true if specified path is a file
Directory Methods
.changeWorkingDirectory(path) Ready Changes the current .workingDirectory
.makeDirectory(path) Creates a directory
.removeDirectory(path) Removes a directory
.copyTree(path) Copies a directory tree.
File Methods
.read(path) Ready Reads contents of a file.
.size(path) Ready Returns size of a file.
.remove(path) Ready Deletes a file.


Module: WebServer

Original PhantomJS API Documentation for this section is in:


Feature Status Notes
.port Ready TCP port on which the server listens for connections.
.listen(binding, callback) Ready Opens TCP port and executes callback for connections.
.listen(binding, opts, callback)  - As per generic .listen() but supports Keep-Alive mode.
.close() Ready Shuts down the server.


var server = require('webserver').create();
var service = server.listen(8080, function(request, response) {
    response.statusCode = 200;

Request Object

Feature Status Notes
.method Ready Request method ('GET''POST', etc.)
.url Ready Path and query string part (if any) of request URL
.httpVersion Ready HTTP Protocol version
.headers Ready HTTP headers as key-value pairs
.post Ready Request body (for 'POST' / 'PUT' methods).
.postRaw Ready Raw request body (without processing form values)

Response Object

Feature Status Notes
.headers Ready HTTP headers as key-value pairs.
.statusCode Ready Sets the returned HTTP status code.
.setHeader(name, value) Ready Adds a HTTP header to response
.header(name) Ready Gets a HTTP header
.setEncoding(encoding) Ready Sets the response encoding. Default: UTF8
.write(data) Ready Sends a data chunk. Can be called multiple times.
.writeHead(statusCode, headers) Ready Sends headers to the browser.
.close() Ready Closes the HTTP connection.
.closeGracefully() Ready Same as .close() but ensures headers are sent.


New Features

These are additional features added into TrifleJS that are not present in PhantomJS.

Feature Status Notes
--test or -t Partial Runs a full regression test.
--emulate:(version) Ready Emulates specific IE versions.
--render:(url) Ready Renders a URL to file and quits.
Object: trifle
.wait(ms) Ready Pauses execution for n milliseconds.


TrifleJS needs YOU

We need your input to keep improving!
Send code samples and bug reports to:

Download v0.3

This code is still very much in beta. Check again for updates.

You can download the binary here if you want to play around with the beta version.

Steven de Salas

Steven de Salas

Steven de Salas is a freelance application developer based in Hobart, Tasmania. Steven specialises in creating rich interfaces and data feeds for web and mobile platforms featuring financial data. Check out his portfolio.

Razvan Radu

Razvan Radu

Razvan is a designer based in Bucharest, Romania. He specializes in logo and web design and has contributed the TrifleJS “trifle” logo to this project.