Browser.PhantomJSDriver Class
This module is a browser plugin for DalekJS. It provides a browser launcher as well the PhantomJS browser itself.
The browser plugin comes bundled with the DalekJS base framework.
You can use the browser plugin beside others (it is the default) by adding a config option to the your Dalekfile:
"browser": ["phantomjs", "chrome"]
Or you can tell Dalek that it should test in this & another browser via the command line:
$ dalek mytest.js -b phantomjs,chrome
The Webdriver Server tries to open Port 9001 by default, if this port is blocked, it tries to use a port between 9002 & 9091 You can specifiy a different port from within your Dalekfile like so:
"browsers": {
"phantomjs": {
"port": 5555
}
}
It is also possible to specify a range of ports:
"browsers": {
"phantomjs": {
"portRange": [6100, 6120]
}
}
If you would like to use a different Phantom version than the one that comes bundled with the driver, your are able to specify its location in your Dalekfile:
"browsers": {
"phantomjs": {
"binary": "~/bin/phantomjs"
}
}
If you would like to preserve the ability to use the bundled version, you can also add an additional browser launcher in your Dalekfile.
"browsers": {
"phantomjs:1.9.1": {
"binary": "~/bin/phantomjs"
}
}
And then launch it like this:
$ dalek mytest.js -b phantomjs:1.9.1
Item Index
Methods
Properties
Methods
_checkPorts
-
deferred
-
error
-
port
Checks if the def. port is blocked & if we need to switch to another port Kicks off the process manager (for closing the opened browsers after the run has been finished) Also starts the chromedriver instance
Parameters:
-
deferred
ObjectPromise
-
error
Null | ObjectError object
-
port
IntegerFound open port
_checkUserDefinedBinary
-
binary
Checks if the binary exists, when set manually by the user
Parameters:
-
binary
StringPath to the browser binary
Returns:
Binary path if binary exists, else false
_checkUserDefinedPorts
-
browser
Process user defined ports
Parameters:
-
browser
ObjectBrowser configuration
_launch
-
deferred
-
data
Checks the data stream from the launched phantom process
Parameters:
-
deferred
ObjectPromise
-
data
BufferConsole output from Ghostdriver
getHost
()
Returns the driver host
getMaxPort
()
Integer
Resolves the maximum range for the driver port
Returns:
port Max WebDriver server port range
getPort
()
Resolves the driver port
Returns:
integer
kill
()
chainable
Kills the PhantomJSDriver processe
launch
-
configuration
-
events
-
config
Launches PhantomJS, negoatiates a port & checks for a user set binary
Parameters:
-
configuration
ObjectBrowser configuration
-
events
EventEmitter2EventEmitter (Reporter Emitter instance)
-
config
Dalek.Internal.ConfigDalek configuration class
Returns:
promise Browser promise
Properties
Verbose version of the browser name
Default: PhantomJS
Default port of the PhantomJSDriver The port may change, cause the port conflict resultion tool might pick another one, if the default one is blocked
Default: 9001
maxPort
Integer
Default maximum port of the Ghostdriver Server The port is the highest port in the range that can be allocated by the Ghostdriver Server
Default: 9091
Default host of the PhantomJSDriver The host may be overriden with a user configured value
Default: localhost
Root path of the PhantomJSDriver
Default: /wd/hub
desiredCapabilities
Object
Default desired capabilities that should be transferred when the browser session gets requested
driverDefaults
Object
Driver defaults, what should the driver be able to access.
Child process instance of the PhantomJS browser