Browser.FirefoxDriver Class
This module is a browser plugin for DalekJS. It provides all a WebDriverServer & browser launcher for Mozilla Firefox & Firefox OS.
The browser plugin can be installed with the following command:
$ npm install dalek-browser-firefox --save-dev
You can use the browser plugin by adding a config option to the your Dalekfile
"browser": ["firefox"]
Or you can tell Dalek that it should test in this browser via the command line:
$ dalek mytest.js -b firefox
Dalek looks for the browser in the std. installation directory, if you installed the browser in a different place, you can add the location of the browser executable to you Dalekfile, because Dalek isnʼt capable of finding the executable yet on its own.
"browsers": [{
"firefox": {
"path": "~/Apps/FirefoxNightlyDebug.app/Contents/MacOS/firefox-bin"
}
}]
The Firefox plugin only implements a subset of Dalekʼs assertions & actions, so if you run into any bugs, the issue is most probably related to missing commands. Please report any issues you find, Thank you :)
The Webdriver Server tries to open Port 9006 by default, if this port is blocked, it tries to use a port between 9007 & 9096 You can specifiy a different port from within your Dalekfile like so:
"browsers": [{
"firefox": {
"port": 5555
}
}]
It is also possible to specify a range of ports:
"browsers": [{
"firefox": {
"portRange": [6100, 6120]
}
}]
If you would like to test Nightly, Aurora oder Firefox OS releases, you can simply apply a snd. argument, which defines the browser type:
$ dalek mytest.js -b firefox:aurora
for Firefox Aurora, and if you would like to use the Firefox OS, just append :os
:
$ dalek mytest.js -b firefox:os
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": [{
"firefox": {
"binary": "/Applications/Custom Located Firefox.app/MacOS/Contents/firefox-bin"
}
}]
This also works for the aurora & Firefox OS builds
"browsers": [{
"firefox:aurora": {
"binary": "/Applications/Custom Located Firefox Aurora.app/MacOS/Contents/firefox-bin"
}
}]
Item Index
Methods
- _afterBinaryFound
- _afterConnectionHasBeenEstablished
- _afterCreatingUserPreferences
- _afterDesktopBinaryFound
- _browserIsReady
- _checkUserDefinedPorts
- _checkUserSetBinary
- _createProfile
- _createProfile
- _getDefaultBinary
- _initiaize
- _killProcess
- _modifyVerboseBrowserName
- _onBrowserStartup
- _resolvePort
- _resolvePort
- _scanMarionettePort
- _startBrowser
- _startByInterval
- findBrowserBinary
- getHost
- getMarionettePort
- getMaxPort
- getPort
- kill
- launch
Methods
_afterBinaryFound
-
configuration
-
deferred
Makes all needed modifications after we are sure if the browser binary has been found
Parameters:
-
configuration
ObjectUser configuration
-
deferred
ObjectPromise
_afterConnectionHasBeenEstablished
-
profileName
-
deferred
Callback that will be invoked after the marionette client has established a connection to the browser & after the webdriver server has been launched correctly
Parameters:
-
profileName
StringName of the user profile
-
deferred
ObjectPromise
_afterCreatingUserPreferences
-
deferred
-
err
Callback that will be executed after the user preferences have been created
Parameters:
-
deferred
ObjectPromise
-
err
Object | NullError or null
_afterDesktopBinaryFound
-
deferred
-
profile
Initiates the browser startup after the desktop binary has been found
Parameters:
-
deferred
ObjectPromise
-
profile
ObjectProfile data
_browserIsReady
-
data
Checks if the browser is ready for communication
Parameters:
-
data
StringOutput from the spawned binary
Returns:
true when ready, false when not
_checkUserDefinedPorts
-
browser
Process user defined ports
Parameters:
-
browser
ObjectBrowser configuration
_checkUserSetBinary
-
userPath
-
deferred
Checks if the binary exists, when set manually by the user
Parameters:
-
userPath
StringPath to the browser binary
-
deferred
ObjectPromise
_createProfile
()
Q.promise
private
Creates a new Firefox profile
Returns:
_createProfile
-
profilePath
Creates user preferences for the profile
Saves them in user.js
in the newly created profile
Parameters:
-
profilePath
StringUser profile directory
Returns:
_getDefaultBinary
()
String
private
Get the default binary location
Returns:
Path to binary
_initiaize
-
opts
Initializes config & properties
Parameters:
-
opts
ObjectConfig options
Returns:
Processed userr config
_killProcess
()
chainable
Kills the currently running browser process
_modifyVerboseBrowserName
-
configuration
Modifies the verbose browser name
Parameters:
-
configuration
ObjectUser configuration
Returns:
Verbose browser name
_onBrowserStartup
-
deferred
-
data
Consumes the console output when the browser is started
Parameters:
-
deferred
ObjectPromise
-
data
StringOutput from the spawned binary
_resolvePort
-
deferred
-
profileName
-
error
-
port
Resolve the WebDriverServer port
Parameters:
-
deferred
ObjectPromise
-
profileName
StringName of the profile
-
error
Object | NullError object if there is one
-
port
IntegerResolved port
_resolvePort
-
deferred
-
profileName
Resolve the WebDriverServer port
Parameters:
-
deferred
ObjectPromise
-
profileName
StringName of the profile
_scanMarionettePort
-
df
Repeatadly checks the status of the marionette port
Parameters:
-
df
ObjectPromise
_startBrowser
-
profilePath
-
profileName
-
deferred
Launches the browser
Parameters:
-
profilePath
StringDirectory that contains the profile
-
profileName
StringName of the profile to use
-
deferred
ObjectPromise
_startByInterval
-
df
-
interval
-
err
-
status
Checks if the browser is available by listening on the marionette socket
Parameters:
-
df
ObjectPromise
-
interval
ObjectReference to the portchecker interval
-
err
Object | NullError or null
-
status
StringStatus of the marionette port
findBrowserBinary
-
options
Locates the browser binary
Parameters:
-
options
ObjectConfig options
Returns:
Promise
getHost
()
String
Returns the driver host
Returns:
host WebDriver server hostname
getMarionettePort
()
Integer
Resolves the marionette port
Returns:
port Marionette server port
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
Shuts down the TCP (Marionette) & HTTP connection (Webdriver), then kills the browser process & cleans up the profiles
launch
-
configuration
-
events
-
config
Launches the FirefoxWebDriverServer, the marionette client, & the browser. Creates a user profile for the browser
Parameters:
-
configuration
ObjectBrowser configuration
-
events
EventEmitter2EventEmitter (Reporter Emitter instance)
-
config
Dalek.Internal.ConfigDalek configuration class
Returns:
promise Browser promise
Properties
aurora
Object
Firefox Aurora
binary
String
Path to the Firefox binary file
Default: null
browserTypes
Object
Different browser types (Aurora / firefox OS) that can be controlled via the Firefox driver
defaultBinaries
Object
Paths to the default Firefox binary files
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 FirefoxWebDriverServer The host may be overridden with a user configured value
Default: localhost
longName
String
Verbose version of the browser name
Default: Mozilla Firefox
marionettePort
Integer
Default port of the Marionette TCP service The port may change, cause the port conflict resolution tool might pick another one, if the default one is blocked
Default: 2828
maxPort
Integer
Default maximum port of the WebDriverServer The port is the highest port in the range that can be allocated by the WebDriverServer
Default: 9096
nightly
Object
Nightly Firefox
os
Object
Firefox OS
path
String
Root path of the FirefoxWebDriverServer
Default: ''
port
Integer
Default port of the FirefoxWebDriverServer The port may change, cause the port conflict resolution tool might pick another one, if the default one is blocked
Default: 9006
profile
Null | Object
Collected data about the created profile, path, name, etc.
Default: null
spawned
Null | Object
Child process instance of the Firefox browser
Default: null