Configure Protractor to Run on Firefox with Single Capability

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):

And in my protractor.conf.js:

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:

  1. https://github.com/serenity-js/tutorial-from-scripts-to-serenity/issues/10
  2. https://stackoverflow.com/questions/38676719/selenium-using-java-the-path-to-the-driver-executable-must-be-set-by-the-webdr
  3. https://github.com/angular/protractor/blob/master/docs/browser-setup.md
  4. https://www.quora.com/How-do-I-run-protractor-test-cases-in-Firefox-browser

Leave a Reply

Your email address will not be published. Required fields are marked *