Adding multiple testing browsers

The biggest benefit of using Selenium is that you can use the same tests to test multiple browsers. If we are interested in just a single browser, like Chrome, we'd be better off using Puppeteer. So, let's add Firefox to our tests.

Firefox, like Chrome, requires a driver to work. Firefox's driver is geckodriver, which uses the Marionette proxy to send instructions to Firefox (Marionette is similar to Chrome's DevTools Protocol):

$ yarn add geckodriver --dev

Now, all we need to do is change the forBrowser call to use "firefox":

this.driver = new webdriver.Builder()  .forBrowser("firefox")  .build();

When we run our tests again, Firefox will be used instead of Chrome.

However, instead of hard-coding the browser ...

Get Building Enterprise JavaScript Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.