SlimerJS is implementing almost the API of Phantomjs .
Here are compatibility tables and other specific API to SlimerJS.
Main differences with PhantomJS 2.1
You'll found in the documentation a list of differences .
of behaviors in the APIs implementation and in the web platform.
Command-line arguments and options
--config=/path/to/config.json Implemented
--cookies-file=/path/to/cookies.txt not applicable. Use profiles instead.
--debug=[yes|no] Implemented, but not everything is displayed. With SlimerJS, it accepts also name of what to debug
--disk-cache=[yes|no] Implemented
--disk-cache-path (phjs 2.1)
--help or -h Implemented
--ignore-ssl-errors=[yes|no]
--load-images=[yes|no] Implemented
--local-storage-path=/path/to/file not applicable. Use profiles instead.
--local-storage-quota=number Implemented
--local-to-remote-url-access=[yes|no]
--local-url-access (phjs 2.0)
--max-disk-cache-size=size Implemented
--offline-storage-path not applicable. Use profiles instead.(phjs 2.1)
--offline-storage-quota (phjs 2.1)
--output-encoding=encoding Implemented
--proxy=address:port Implemented
--proxy-auth=username:password Implemented
--proxy-type=[http|socks5|none|auto|system|config-url] Implemented
--remote-debugger-port=number
--remote-debugger-autorun=[yes|no]
--script-encoding=encoding
--script-language=[language] (phjs 2.0)
--ssl-protocol=[SSLv3|TLSv1|TLSv1.1|TLSv1.2|any|TLS] Implemented. No support of sslv2. By default TLS.
--ssl-certificates-path=/path/to/dir not applicable. Use profiles instead.
--ssl-ciphers (phjs 2.0)
--ssl-client-certificate-file (phjs 2.1)
--ssl-client-key-file (phjs 2.1)
--ssl-client-key-passphrase (phjs 2.1)
--version or -v Implemented
--webdriver or --wd or -w Implemented (experimental)
--webdriver=ip:port Implemented (experimental)
--webdriver-logfile=/path/to/logfile Implemented (experimental)
--webdriver-loglevel=[ERROR|WARN|INFO|DEBUG] Implemented (experimental)
--webdriver-selenium-grid-hub=url Implemented (experimental)
--web-security=[yes|no]
script path Implemented
script arguments Implemented
args Implemented (deprecated, removed in phjs 2.0)
cookies Implemented
cookiesEnabled Implemented
defaultPageSettings Implemented
libraryPath Implemented (deprecated)
outputEncoding Implemented (with support of special value 'binary' for system.stdout, Slimerjs only)
page Not implemented. Irrelevant for SlimerJS
remoteDebugPort (phjs 2.1)
scriptName Implemented (deprecated, removed in phjs 2.0)
version Implemented. Gives the PhantomJS version which is compatible to
the SlimerJS implementation.
webdriverMode Implemented
aboutToExit Implemented
addCookie(cookie) Implemented
clearCookies() Implemented
defaultErrorHandler(message, stack) Implemented
deleteCookie(cookieName) Implemented
debugExit(returnValue) Implemented
exit(returnValue) Implemented
fullyDecodeUrl(url) Implemented (phjs 2.1)
injectJs(filename) Implemented
loadModule(moduleSource, filename)
onerror(msg, trace) Implemented
proxy() (phjs 2.1)
resolveRelativeUrl(url, base) Implemented (phjs 2.1)
setProxy(ip, port, proxyType, user, password) (phjs 2.0)
It will contain API that does not exists in PhantomJS.
version Implemented. Gives the version of SlimerJS
clearHttpAuth() Implemented.
exit() Implemented.
require(modulename) Implemented
require.paths Implemented. SlimerJS only. Array of path where modules can be found
canGoBack Implemented
canGoForward Implemented
clipRect Implemented
content Implemented.
captureContent Implemented. list of regexp matching content
types of resources for which you want to retrieve
the content. The content is then set on the body
property of the response object received by your
onResourceReceived callback (SlimerJS only)
cookies Implemented (phjs 2.0)
cookieJar (phjs 2.0)
customHeaders Implemented
event Implemented
focusedFrameName Implemented
frameContent Implemented
frameName Implemented
framePlainText Implemented
frameTitle Implemented
frameUrl Implemented
framesCount Implemented
framesName Implemented
libraryPath Implemented
loading Implemented
loadingProgress Implemented
navigationLocked Implemented
offlineStoragePath Implemented
offlineStorageQuota Implemented
ownsPages Implemented
pages Implemented
pagesWindowName Implemented
paperSize Implemented. 'header' and 'footer' properties are not supported yet.
plainText Implemented
scrollPosition Implemented
settings Implemented
settings.javascriptEnabled Implemented
settings.loadImages Implemented
settings.localToRemoteUrlAccessEnabled
settings.XSSAuditingEnabled
settings.webSecurityEnabled
settings.javascriptCanOpenWindows
settings.javascriptCanCloseWindows
settings.userAgent Implemented
settings.userName Implemented
settings.password Implemented
settings.proxy (phjs 2.1)
settings.maxAuthAttempts Implemented
settings.resourceTimeout Implemented
settings.plainTextAllContent Implemented (SlimerJS only)
title Implemented
url Implemented
viewportSize Implemented
windowName Implemented
zoomFactor Implemented
<tr><td>setCookieJar(cookieJar) </td><td>(phjs 2.0)</td></tr>
<tr><td>setCookieJarFromQObject(Qobject) </td><td>not implemented, irrelevant (phjs 2.0)</td></tr>
<tr><td>setProxy(url) </td><td>(phjs 2.1)</td></tr>
<tr><td>stop() </td><td>Implemented</td></tr>
<tr><td>stopJavascript() </td><td>Implemented (phjs 2.0)</td></tr>
<tr><td>switchToFocusedFrame() </td><td>Implemented</td></tr>
<tr><td>switchToFrame(frameName) </td><td>Implemented</td></tr>
<tr><td>switchToFrame(framePosition) </td><td>Implemented</td></tr>
<tr><td>switchToChildFrame(frameName) </td><td>Implemented. deprecated</td></tr>
<tr><td>switchToChildFrame(framePosition) </td><td>Implemented. deprecated</td></tr>
<tr><td>switchToMainFrame() </td><td>Implemented</td></tr>
<tr><td>switchToParentFrame() </td><td>Implemented</td></tr>
<tr><td>uploadFile(selector, filename) </td><td>Implemented</td></tr>
addCookie(Cookie) Implemented
childFramesCount() Implemented. deprecated
childFramesName() Implemented. deprecated
clearCookies() Implemented
clearMemoryCache() (phjs 2.0)
close() Implemented
currentFrameName() Implemented. deprecated
deleteCookie(cookieName) Implemented
evaluateJavascript(str) implemented
evaluate(function, arg1, arg2,...) implemented
evaluateASync(function, arg1, arg2,...) implemented
getPage(windowName) Implemented
go(index) Implemented
goBack() Implemented
goForward() Implemented
includeJs(url, callback) implemented
injectJs(filename) Implemented
open(url) Implemented. SlimerJS only: it returns a promise
open(url, callback) Implemented. SlimerJS only: it returns a promise
open(url, httpConf) Implemented. SlimerJS only: it returns a promise. Only GET and POST method are supported.
open(url, httpConf, callback) Implemented. SlimerJS only: it returns a promise. Only GET and POST method are supported.
open(url, operation, data) Implemented. SlimerJS only: it returns a promise. Only GET and POST method are supported.
open(url, operation, data, callback) Implemented. SlimerJS only: it returns a promise. Only GET and POST method are supported.
open(url, operation, data, headers, callback) Implemented. SlimerJS only: it returns a promise. Only GET and POST method are supported.
openUrl(url, httpConf, settings) Implemented. SlimerJS only: it returns a promise. Only GET and POST method are supported.
release() Implemented
reload() Implemented
render(filename, options) Implemented. Only PNG, JPG, BMP, ICO and PDF are supported for now.
renderBytes(format, options) Implemented. SlimerJS only. Only PNG, BMP, ICO and JPG are supported for now.
renderBase64(format, options) Implemented. Only PNG and JPG are supported for now.
sendEvent(mouseEventType, mouseX, mouseY, button='left') Implemented
sendEvent(keyboardEventType, keyOrKeys) Implemented
setContent(content, url) Implemented
onAlert Implemented
onAuthPrompt Implemented (SlimerJS only)
onCallback Implemented
onClosing Implemented
onConfirm Implemented
onConsoleMessage Implemented (SlimerJS only: the callback receives the lineNumber and the sourceID, contrary to PhantomJS)
onError Implemented (SlimerJS issue: For errors from the webpage directly, the stack is not available..)
onFilePicker Implemented
onInitialized Implemented
onLoadFinished Implemented SlimerJS only: the callback receives 3 parameters: the status ("success" or "fail"), the url and true if this is a frame that is loaded
onLoadStarted Implemented SlimerJS only: the callback receives 2 parameters: the url and true if this is a frame that is loaded
onLongRunningScript Implemented (phjs 2.0)
onNavigationRequested Implemented. SlimerJS issue: navigationType is always "Undefined" and isMainFrame is irrelevant
onPageCreated Implemented
onPrompt Implemented
onRepaintRequested (phjs 2.0)
onResourceError Implemented
onResourceRequested Implemented
onResourceReceived Implemented
onResourceTimeout Implemented
onUrlChanged Implemented
Methods that send signals (private methods):
closing(page) Implemented
initialized() Implemented
javaScriptAlertSent(message) Implemented
javaScriptConsoleMessageSent(message) Implemented
loadFinished(status) Implemented
loadStarted() Implemented
navigationRequested(url, navigationType, navigationLocked, isMainFrame) Implemented
rawPageCreated(page) Implemented
repaintRequested() (phjs 2.0)
resourceError(resourceError) Implemented
resourceReceived(request) Implemented
resourceRequested(resource) Implemented
urlChanged(url) Implemented
resourceError object received by onResourceError
id Implemented (phjs 2.0)
url Implemented
errorCode Implemented
errorString Implemented
status Implemented (phjs 2.0)
statusText Implemented (phjs 2.0)
request object received by onResourceRequested
id Implemented
method Implemented
url Implemented
time Implemented
headers Implemented
request controller object received by onResourceRequested
abort() Implemented
changeUrl(url) Implemented
setHeader(key, value, merge) Implemented (phjs 2.0)
response object received by onResourceReceived
id Implemented
headers Implemented
body Implemented (SlimerJS only, see webpage.captureContent)
bodySize Implemented
contentType Implemented
contentCharset Implemented (SlimerJS only)
imageInfo Implemented (SlimerJS only, for images)
redirectURL Implemented
referrer Implemented (SlimerJS only)
stage Implemented
status Implemented
statusText Implemented
time Implemented
url Implemented
cookies (phjs 2.0)
addCookie(cookie) (phjs 2.0)
addCookieFromMap(cookie, url) (phjs 2.0)
addCookiesFromMap(cookiesList, url) (phjs 2.0)
cookiesToMap(url) (phjs 2.0)
cookieToMap(name, url) (phjs 2.0)
deleteCookie(name, url) (phjs 2.0)
clearCookies() (phjs 2.0)
close() (phjs 2.0)
create(path) -> cookieJar (phjs 2.0)
args Implemented
env Implemented
isSSLSupported
os Implemented. SlimerJS only: an additional method on this object: isWindows()
pid Implemented
platform Implemented
stdout Implemented
stdin Implemented
stderr Implemented
standardout Implemented (phjs 2.0)
standardin Implemented (phjs 2.0)
standarderr Implemented (phjs 2.0)
separator Implemented
workingDirectory Implemented
Note that it is a property, to be compatible
with PhantomJS. In the CommonJS FileSystem
specification, it supposed to be a method
<tr><td>makeDirectory(path) </td><td>Implemented</td></tr>
<tr><td>removeDirectory(path) </td><td>Implemented</td></tr>
<tr><td>makeTree(path) </td><td>Implemented</td></tr>
<tr><td>removeTree(path) </td><td>Implemented</td></tr>
<tr><td>copyTree(source, destination) </td><td>Implemented</td></tr>
<tr><td>list(path) </td><td>Implemented</td></tr>
<tr><td>readLink(path) </td><td>Implemented</td></tr>
<tr><td>lastModified(path) Date </td><td>Implemented</td></tr>
<tr><td>exists(path) </td><td>Implemented</td></tr>
<tr><td>isFile(path) </td><td>Implemented</td></tr>
<tr><td>isDirectory(path) </td><td>Implemented</td></tr>
<tr><td>isLink(path) </td><td>Implemented</td></tr>
<tr><td>isReadable(path) </td><td>Implemented</td></tr>
<tr><td>isWritable(path) </td><td>Implemented</td></tr>
<tr><td>absolute(path) </td><td>Implemented</td></tr>
<tr><td>join(base) </td><td>Implemented</td></tr>
<tr><td>split(path) </td><td>Implemented</td></tr>
<tr><td>size(path) </td><td>Implemented</td></tr>
<tr><td>isAbsolute(path) </td><td>Implemented (not a CommonJS FileSystem method)</td></tr>
<tr><td>isExecutable(path) </td><td>Implemented (not a CommonJS FileSystem method)</td></tr>
<tr><td>changeWorkingDirectory(path) </td><td>Implemented</td></tr>
<tr><td>fromNativeSeparators(path) </td><td></td></tr>
<tr><td>toNativeSeparators(path) </td><td></td></tr>
open(path, mode) Implemented
read(path) Implemented
write(path, content, mode) Implemented
copy(source, destination) Implemented
move(source, destination) Implemented
remove(path) Implemented
touch(path) Implemented
Other additional methods not provided in PhantomJS, but that
are part of the CommonJS FileSystem specification
<tr><td>listTree(path) </td><td></td></tr>
<tr><td>listDirectoryTree(path) </td><td></td></tr>
<tr><td>link(source, target) </td><td></td></tr>
<tr><td>hardLink(source, target) </td><td></td></tr>
<tr><td>same(source, target) </td><td></td></tr>
<tr><td>workingDirectoryPath() </td><td></td></tr>
<tr><td>normal(path) </td><td></td></tr>
<tr><td>canonical(path) </td><td></td></tr>
<tr><td>directory(path) </td><td>Implemented</td></tr>
<tr><td>base(path) </td><td>Implemented</td></tr>
<tr><td>extension(path) </td><td>Implemented</td></tr>
rename(path, name) Implemented
atEnd() Implemented
read() Implemented
readLine() Implemented
write(data) Implemented
writeLine(data) Implemented
flush() Implemented
close() Implemented
seek(pos)
getEncoding() Implemented (phjs 2.0)
setEncoding(encoding) Implemented (phjs 2.0)
port Implemented
close() Implemented
listenOnPort(port, options)
listen(port, callback) Implemented. The callback is called for every
http request. Don't give it if you use one of
register* methods (it calls
registerPrefixHandler("/",
callback);
)
listen(port, options, callback) This form of call is recognized but
options are ignored in SlimerJS
onNewRequest
registerFile(path, filePath) Implemented (SlimerJS only). Maps the given path to a file.
registerDirectory(path, directoryPath) Implemented (SlimerJS only). Maps a path to a dir (directoryPath)
registerPathHandler(path, callback) Implemented (SlimerJS only). Register a callback that will be called when an HTTP client request the given path.
registerPrefixHandler(prefixPath, callback) Implemented (SlimerJS only). Register a callback that will be called when an HTTP client request a path starting with prefixPath.
method Implemented
url Implemented
httpVersion Implemented
headers Implemented
post Implemented
postRaw Implemented
path Implemented (SlimerJS only). Contains the path part of the URL (Readonly)
queryString Implemented (SlimerJS only). Contains the query part of the URL (Readonly)
headers Implemented
header(name) Implemented
setHeader(name, value) Implemented
setEncoding(encoding) Implemented
statusCode Implemented
write(data) Implemented
writeHead(statusCode, headers) Implemented
close() Implemented
closeGracefully() Implemented
spawn(cmd, args, opts)
exec(cmd, opts, cb) (not implemented in PhantomJS)
execFile(file, args, options, callback)
fork(modulePath, args, options) (not implemented in PhantomJS)
context object (returned by execFile and spawn)
pid
kill(signal)
on(event, callback)
stdout.on(event, callback)
stderr.on(event, callback)
stdin.write(chunk, encoding)
stdin.close()
stdin.end()