Browser.ChromeDriver Class
This module is a browser plugin for DalekJS. It provides all a WebDriverServer & browser launcher for Google Chrome.
The browser plugin can be installed with the following command:
$ npm install dalek-browser-chrome --save-dev
You can use the browser plugin by adding a config option to the your Dalekfile
"browser": ["chrome"]
Or you can tell Dalek that it should test in this browser via the command line:
$ dalek mytest.js -b chrome
The Webdriver Server tries to open Port 9002 by default, if this port is blocked, it tries to use a port between 9003 & 9092 You can specifiy a different port from within your Dalekfile like so:
"browsers": [{
"chrome": {
"port": 5555
}
}]
It is also possible to specify a range of ports:
"browsers": [{
"chrome": {
"portRange": [6100, 6120]
}
}]
If you would like to test Chrome Canary oder Chromium releases, you can simply apply a snd. argument, which defines the browser type:
$ dalek mytest.js -b chrome:canary
for canary, and if you would like to use chromium, just append :chromium:
$ dalek mytest.js -b chrome:chromium
This will only work if you installed your browser in the default locations, if the browsers binary is located in a non default location, you are able to specify its location in your Dalekfile:
"browsers": [{
"chrome": {
"binary": "/Applications/Custom Located Chrome.app/MacOS/Contents/Chrome"
}
}]
This also works for the canary & chromium builds
"browsers": [{
"chrome": {
"binary": "/Applications/Custom Located Chrome.app/MacOS/Contents/Chrome"
}
}]
Item Index
Methods
- _catchDriverLogs
- _checkPorts
- _checkProcesses
- _checkUserDefinedBinary
- _checkUserDefinedPorts
- _fetchProcessName
- _filterProcessItemsNix
- _filterProcessItemsWin
- _killNix
- _killWindows
- _modifyVerboseBrowserName
- _processes
- _processesNix
- _processesWin
- _processListNix
- _processListWin
- _splitProcessListNix
- _splitProcessListWin
- _startChromedriver
- _unlinkChromedriverLog
- getHost
- getMaxPort
- getPort
- kill
- launch
Methods
_catchDriverLogs
-
deferred -
data
Watches the chromedriver console output to capture the starting message
Parameters:
-
deferredObjectPromise
-
dataBufferChromedriver console output
_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:
-
deferredObjectPromise
-
errorNull | ObjectError object
-
portIntegerFound open port
_checkProcesses
-
err -
result
Kills all associated processes
Parameters:
-
errObject | NullError object or null
-
resultArrayList of running processes
_checkUserDefinedBinary
-
binary
Checks if the binary exists, when set manually by the user
Parameters:
-
binaryStringPath to the browser binary
Returns:
Binary exists
_checkUserDefinedPorts
-
browser
Process user defined ports
Parameters:
-
browserObjectBrowser configuration
_fetchProcessName
-
configuration
Change the process name for browser instances like Canary & Chromium
Parameters:
-
configurationObjectUser configuration
Returns:
Verbose browser name
_filterProcessItemsNix
-
item
Filters empty process list entries on *NIX
Parameters:
-
itemStringItem to check
Returns:
Item or falsy
_filterProcessItemsWin
-
result -
process
Processes (transforms) the list of processes
Parameters:
-
resultArrayReference to the result process list
-
processObjectSingle piece of process information
_killNix
-
processID
Kills a process
Parameters:
-
processIDIntegerProcess ID
_killWindows
-
pid
Kills a process (based on a PID) that was not opened BEFORE Dalek has been started
Parameters:
-
pidIntegerProcess id
_modifyVerboseBrowserName
-
configuration
Modifies the verbose browser name
Parameters:
-
configurationObjectUser configuration
Returns:
Verbose browser name
_processes
-
platform -
fn
Tracks running browser processes for chrome on mac & linux
Parameters:
-
platformStringCurrent OS
-
fnFunctionCallback
_processesNix
-
fn
Lists all chrome processes on *NIX systems
Parameters:
-
fnFunctionCalback
_processesWin
-
callback
Lists all running processes (win only)
Parameters:
-
callbackFunctionReceives the process object as the only callback argument
_processListNix
-
fn -
err -
stdout
Deserializes a process list on nix
Parameters:
-
fnFunctionCalback
-
errObject | NullError object
-
stdoutStringOutput of the process list shell command
_processListWin
-
callback -
err -
stdout
Deserializes the process list on win
Parameters:
-
callbackFunctionCallback to be executed after the list has been transformed
-
errObject | NullError if error, else null
-
stdoutStringOutput of the process list command
_splitProcessListNix
-
result -
line
Reformats the process list output on *NIX systems
Parameters:
-
resultArrayReference to the process list
-
lineStringSingle process in text representation
_splitProcessListWin
-
p -
line
Filters empty lines out of the process result
Parameters:
-
pArrayReference to the process list
-
lineStringProcess item
_startChromedriver
-
deferred -
error -
result
Spawns an instance of Chromedriver
Parameters:
-
deferredObjectPromise
-
errorNull | ObjectError object
-
resultStringList of open chrome processes BEFORE the test browser has been launched
_unlinkChromedriverLog
-
retry
Remove the chromedriver log that is written to the current working directory
Parameters:
-
retryBoolDelete has been tried min 1 time before
getHost
()
String
Returns the driver host
Returns:
host WebDriver server hostname
getMaxPort
()
Integer
Resolves the maximum range for the driver port
Returns:
port Max WebDriver server port range
getPort
()
Integer
Resolves the driver port
Returns:
port WebDriver server port
kill
()
chainable
Kills the ChromeWebDriverServer & Chrome browser processes
launch
-
configuration -
events -
config
Launches the ChromeWebDriverServer (which implicitly launches Chrome itself) and checks for an available port
Parameters:
-
configurationObjectBrowser configuration
-
eventsEventEmitter2EventEmitter (Reporter Emitter instance)
-
configDalek.Internal.ConfigDalek configuration class
Returns:
promise Browser promise
Properties
browserTypes
Object
Different browser types (Canary / Chromium) that can be controlled via the Chromedriver
canary
Object
Chrome Canary
chromium
Object
Chromium
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.
host
String
Default host of the ChromeWebDriverServer The host may be overridden with a user configured value
Default: localhost
longName
String
Verbose version of the browser name
Default: Google Chrome
maxPort
Integer
Default maximum port of the ChromeWebDriverServer The port is the highest port in the range that can be allocated by the ChromeWebDriverServer
Default: 9092
openProcesses
Array
Chrome processes that are running on startup, and therefor shouldn`t be closed
Default: []
path
String
Root path of the ChromeWebDriverServer
Default: /wd/hub
port
Integer
Default port of the ChromeWebDriverServer The port may change, cause the port conflict resolution tool might pick another one, if the default one is blocked
Default: 9002
processName
String
Name of the process (platform dependent) that represents the browser itself
Default: chrome.exe / Chrome
spawned
Null | Object
Child process instance of the Chrome browser
Default: null
