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

API Status (63%)

This is the overall status of the API implementation: 110 components in 174 total (ie 63%)

Feature Status Notes
Command Line Options Partial 5 out of 12 options
Global Methods Ready .require() for CommonJS module definition
Object: phantom Partial 9 out of 12 members
Module: System Ready 5 out of 5 members
Module: WebPage Partial 32 out of 86 members
Module: FileSystem Ready 35 out of 35 members
Module: WebServer Ready 19 out of 19 members
New Features Partial 5 out of 6 options (IE emulation etc)

Latest Updates

For latest updates from the developer follow @triflejs.

Download Beta

This is still very much work-in-progress. Click here for binaries.

Command Line Options

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

C:> TrifleJS.exe --version
1.7.0

Original PhantomJS API Documentation for this section is in:

https://github.com/ariya/phantomjs/wiki/API-Reference#command-line-options

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] To Do Ignores SSL errors.
--load-images=[true/false] To Do Load all inlined images (default true).
--output-encoding=encoding To Do Encoding for terminal output (default utf8).
--proxy=address:port Ready Specifies the proxy server to use.
--proxy-type=[http/socks5/none] To Do Specifies the type of the proxy server.
--proxy-auth=user:passw Ready Authentication info for the proxy.
--script-encoding=encoding To Do Encoding for starting script (default utf8).
--web-security=[true/false] To Do Prevents cross-domain XHR (default true).
--config=/path/to/config.json To Do JSON replacement for command switches.

 

Object: phantom

Original PhantomJS API Documentation for this section is in:

https://github.com/ariya/phantomjs/wiki/API-Reference-phantom

Feature Status Notes
Properties
.args Ready Arguments passed to the script.
.cookies Ready Get or set Cookies for any domain.
.cookiesEnabled Ready 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.
Methods
.addCookie({cookie}) Ready Add a Cookie to the CookieJar.
.clearCookies() To Do Delete all Cookies.
.deleteCookie(name) To Do Deletes a Cookie.
.exit(returnValue) Ready Exits program with return value.
.injectJS(filename) Ready Injects external scripts
Events
#onError To Do Errors not caught by a WebPage#onError

 

Module: System

Original PhantomJS API Documentation for this section is in:

https://github.com/ariya/phantomjs/wiki/API-Reference-System

Feature Status Notes
Properties
.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: WebPage

Original PhantomJS API Documentation for this section is in:

https://github.com/ariya/phantomjs/wiki/API-Reference-WebPage

Feature Status Notes
Properties
.canGoBack Ready true if browser can navigate back.
.canGoForward Ready true if browser can navigate forward.
.clipRect To Do Page area rasterized during .render()
.content Ready HTML content of the web page.
.cookies To Do Get/set cookies visible in current URL.
.customHeaders Ready Additional HTTP headers sent to server.
.frameContent To Do HTML content of active frame
.frameName To Do Name of active window frame
.framePlainText To Do Plain Text body in active window frame
.frameTitle To Do Title of active window frame
.frameUrl To Do Url of active window frame
.framesCount Ready Number of frames in browser window
.framesName Ready List of names for frames in browser window.
.paperSize To Do Size of the page when rendered as PDF.
.plainText Ready Content of the web page in plain text.
.settings To Do Various settings of the web page.
.scrollPosition To Do 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 Ready Name of the main browser window.
.zoomFactor Ready Scaling factor for rendering pages.
Methods
.addCookie({cookie}) To Do Add a cookie to the page.
.clearCookies() To Do Delete all Cookies for current domain.
.close() Ready Closes page to release memory.
.deleteCookie(name) To Do Deletes a Cookie in current domain.
.evaluate(function, arg1, arg2,..) Ready Evaluates function inside current page.
.evaluateAsync(function) To Do evaluate() without blocking execution.
.evaluateJavaScript(str) Ready Evaluates script in current page.
.getPage(windowName) To Do Gets a page inside a window frame.
.goBack() Ready Goes back to previous page in history
.goForward() Ready Goes forward to next page in history
.go(n) Ready Goes back or forwards by n pages in history
.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) To Do Opens url with specific settings.
.reload() Ready Reloads current page.
.render(filename) Ready Renders page to specified filename
.renderBase64(format) Ready Renders page as Base64-encoded string
.stop() Ready Stops loading the current page.
Events
#onAlert Ready Fires for alert() calls on page.
#onCallback Ready Fires for window.callPhantom calls.
#onClosing To Do Fires on window.close()
#onConfirm Ready Fires for confirm() calls on page.
#onConsoleMessage To Do 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 To Do Fires for all navigations events.
#onPageCreated To Do Fires on child page created – ie window.open().
#onPrompt Ready Fires when prompt() call made on page.
#onResourceRequested To Do Fires for all requests resources (image, css, js etc).
#onResourceCompleted To Do Fires when resources are received.
#onResourceTimeout To Do Fires when resources requested time out.
#onResourceError (v1.9) Fires when error occurs loading resource.
#onUrlChanged To Do Fires whenever URL changes.

 

Module: WebServer

Original PhantomJS API Documentation for this section is in:

https://github.com/ariya/phantomjs/wiki/API-Reference-WebServer

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

Example

var server = require('webserver').create();
var service = server.listen(8080, function(request, response) {
    response.statusCode = 200;
    response.write('<html><body>Hello!</body></html>');
    response.close();
});

Request Object

Feature Status Notes
Properties
.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
Properties
.headers Ready HTTP headers as key-value pairs.
.statusCode Ready Sets the returned HTTP status code.
Methods
.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
COMMAND LINE
--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
.version Ready Version of TrifleJS
.emulation Ready Target IE Version for Emulation (set using --emulate=IE9).
.wait(ms) Ready Pauses execution for n milliseconds.

 

YOU TOO CAN HELP

TrifleJS needs YOU

We need your input to keep improving!
Send code samples and bug reports to:
https://github.com/sdesalas/trifleJS/issues


Download v0.4

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.

Roadmap

  • v0.6 – 100% of PhantomJS non-WebPage modules, 80% of WebPage module API
  • v0.7 – 100% of PhantomJS Core API (v1.7) + internal unit tests
  • v0.8CasperJS Support (implement Test suite and fixes)
  • v0.9 – Testing and Support for Windows platforms (after XP SP2).
  • v1.0 – Only minor Bugfixes left
  • v1.1 – Nice to haves (WebDriver, improved IPC, REPL Autocompletion etc)
Steven de Salas

Steven de Salas

Steven de Salas is a freelance application developer based in Hobart, Tasmania. He is the main contributor of the TrifleJS project.

 

 

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.