#149: Multiple Browsers in Selenium Grid
One of the greatest benefits of Selenium Grid is to run Selenium against multiple browsers. This can be multiple instances of one web browser that we run in parallel, or browsers from different vendors. Let's see how we can configure a flexible solution without much effort.
Multiple containers
We can use the official browser-specific images and combine them to a flexible grid. However, starting those containers one by one will be a pain. With docker-compose we already have a tool that is great to orchestrate a few containers. All we need to do is to create a docker-compose.yaml file and start it.
Create a docker-compose.yaml file
To create a flexible Selenium grid, we need one hub container that coordinates everything and for each browser instance we add a container called a node. The nodes need to know where the hub is and how they can reach it.
This docker-compose.yaml file creates one hub and four nodes (1 for Chrome, 1 for Edge, and 2 for Firefox):
Run the grid
Since we use Docker compose, we can use this command to start our grid:
If you go to the hub (http://localhost:4444/ui#), you should see something like this:

Use a specific browser
If we want to run our code against a Firefox browser, we can reuse the code from the last post:
If we want to run with Chrome, we can change it to this:
And for Edge, we can use this code:
Everything else in our code is the same and works for each browser.
Next
We can extend our docker-compose.yaml and add more containers as our requirements grow. Next week we look at creating a more dynamic Selenium Grid.