Controls Firefox using the WebDriver interface via geckodriver without Selenium.
npm install grunt-geckodriver


Controls Firefox using the WebDriver interface via geckodriver without Selenium.
If you use a modern test driver like [webdriverio], you will not need [Selenium] to run the tests, because the browser driver itself implements the [WebDriver] interface. This module provides a [Grunt] multi-task for installing, starting and stopping the [geckodriver] executable. You take care of installing Firefox.
This task, [grunt-chromedriver] and [grunt-safaridriver] can be used as a replacement for [grunt-selenium-standalone] for tasks like [grunt-html-dom-snapshot], to simplify the whole scenario by removing [Selenium] and [Java] from the requirements.
You need [node >= 10][node], [npm] and [grunt >= 1.0.0][Grunt] installed and
your project build managed by a [Gruntfile]. If you have not used Grunt before,
be sure to check out the [Getting Started] guide, as it explains how to create
a Gruntfile as well as install and use Grunt plugins. Once you are familiar
with that process, you may install this plugin with this command:
npm install grunt-geckodriver --save-dev
Add the geckodriver entry with one or more tasks to the options of thegrunt.initConfig method in Gruntfile.js:
``js`
grunt.initConfig({
geckodriver: {
default: {}
}
});
Load the plugin:
`javascript`
grunt.loadNpmTasks('grunt-geckodriver');
Add use the task to start and stop the browser driver before and after the tests:
`js`
grunt.registerTask('default', ['geckodriver:default:start', ..., 'geckodriver:default:stop']);
Default task options support the most usual usage scenario:
`js`
geckodriver: {
default: {
port: 4444,
findAvailablePort: false,
args: [],
force: false
}
}
#### port
Type: Number4444
Default value:
The port for the geckodriver to listen to. If findAvailablePort is set totrue, this port will be used to start the search for a free port with.
Default value: falseIf set to
true, the value of port will be used to start the search for a
free port with.$3
Type: Array
Default value: []Command-line arguments for the
geckodriver executable. Available ones: --connect-existing Connect to an existing Firefox instance
--jsdebugger Attach browser toolbox debugger for Firefox
-v Log level verbosity (-v for debug and -vv for trace level)
-b, --binary Path to the Firefox binary
--log Set Gecko log level [possible values: fatal, error,
warn, info, config, debug, trace]
--marionette-host Host to use to connect to Gecko
[default: 127.0.0.1]
--marionette-port Port to use to connect to Gecko
[default: system-allocated port]
--host Host IP to use for WebDriver server [default: 127.0.0.1]
-p, --port Port to use for WebDriver server [default: 4444]
$3
Type: Boolean
Default value: falseIf set to
true, it suppresses failures. Instead of making the Grunt fail,
the errors will be written only to the console.$3
If
findAvailablePort is set to true, the actual chosen port can be read by:`js
grunt.config.get(geckodriver.)
`As soon es the browser driver process starts listening, an event will be
triggered with the actually chosen port:
`js
grunt.event.on(geckodriver., port => {...})
``In lieu of a formal styleguide, take care to maintain the existing coding
style. Add unit tests for any new or changed functionality. Lint and test
your code using Grunt.
Copyright (c) 2020-2022 Ferdinand Prantl
Licensed under the MIT license.
[node]: https://nodejs.org
[npm]: https://npmjs.org
[Grunt]: https://gruntjs.com
[Gruntfile]: https://gruntjs.com/sample-gruntfile
[Getting Gtarted]: https://github.com/gruntjs/grunt/wiki/Getting-started
[Selenium]: http://www.seleniumhq.org/download/
[geckodriver]: https://github.com/giggio/node-geckodriver#readme
[webdriverio]: http://webdriver.io/
[Java]: https://java.com/en/download/
[WebDriver]: https://www.w3.org/TR/webdriver/
[grunt-html-dom-snapshot]: https://github.com/prantlf/grunt-html-dom-snapshot#readme
[grunt-selenium-standalone]: https://github.com/zs-zs/grunt-selenium-standalone#readme
[grunt-chromedriver]: https://github.com/prantlf/grunt-chromedriver#readme
[grunt-safaridriver]: https://github.com/prantlf/grunt-safaridriver#readme