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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.