I have been developing tests using SerenityJS, which has Protractor running underneath it, to perform UI testing in a BDD fashion.
The tests have been developed initially on MacOS with Chrome, as the tests mature, we wanted to extends our tests to run Firefox on MacOS..
Firefox uses the Gecko Driver. After some trial and error as well as extended research on how people have done it, I have determined the following configuration to be the keys to have tests run on firefox.
I have a separate file that contains specific configuration for browsers (browserConfig.js), and exports the configuration to be used (The protractor Github documentation is really helpful here):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
const chrome = { 'browserName': 'chrome', 'chromeOptions': { 'args': [ 'disable-infobars', ] } }; const firefox = { 'browserName': 'firefox', 'marionette': true, }; module.exports = { chrome, firefox } |
And in my protractor.conf.js
:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
const browserConfig = require('./browserConfig'); exports.config = { // <other code and configuration goes here> // This is needed to run tests on firefox // This configuration does not interfere with operation of other browser directConnect: true, // configObject.capabilities = browserConfig['chrome']; capabilities: browserConfig['firefox'], }; |
Here enabling directConnect
is crucial to have the entire test running, there is a discussion here, which helped me a great deal in figuring it out. basically the line tells protractor to connect and run the gecko driver directly.
Note that I am retrieving the firefox configuration from browserConfig
to use in protractor.config.js
.
Protractor has a sample config file on Github which is also a good reference
So with those configurations in place, I am able to run tests on firefox. Now you can have yours run on firefox too.
Enjoy!
A few more good references are:
- https://github.com/serenity-js/tutorial-from-scripts-to-serenity/issues/10
- https://stackoverflow.com/questions/38676719/selenium-using-java-the-path-to-the-driver-executable-must-be-set-by-the-webdr
- https://github.com/angular/protractor/blob/master/docs/browser-setup.md
- https://www.quora.com/How-do-I-run-protractor-test-cases-in-Firefox-browser