Complete the code to start a Selenium Grid hub container using Docker.
docker run -d -p 4444:4444 --name selenium-hub [1]
The Selenium Grid hub runs the central server. The correct Docker image is selenium/hub:4.8.0.
Complete the code to start a Chrome node container and connect it to the Selenium Grid hub network.
docker run -d --network [1] --name chrome-node -e SE_EVENT_BUS_HOST=selenium-hub selenium/node-chrome:4.8.0
The Chrome node must join the same Docker network as the Selenium Grid hub, commonly named selenium-grid.
Fix the error in the Docker command to start a Firefox node connected to the Selenium Grid hub.
docker run -d --network selenium-grid --name firefox-node -e SE_EVENT_BUS_HOST=[1] selenium/node-firefox:4.8.0
The environment variable SE_EVENT_BUS_HOST must be set to the hub container's name selenium-hub so the node can connect correctly.
Fill both blanks to create a Docker network and start the Selenium Grid hub attached to it.
docker network [1] selenium-grid docker run -d -p 4444:4444 --network [2] --name selenium-hub selenium/hub:4.8.0
First, create the Docker network named selenium-grid with docker network create selenium-grid. Then start the hub attached to this network.
Fill all three blanks to write a Java Selenium test that connects to the Selenium Grid hub and opens a Chrome browser.
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.remote.RemoteWebDriver; import java.net.URL; public class GridTest { public static void main(String[] args) throws Exception { ChromeOptions options = new ChromeOptions(); WebDriver driver = new RemoteWebDriver(new URL("[1]"), [2]); driver.get("https://example.com"); System.out.println(driver.getTitle()); driver.quit(); } }
The Selenium Grid hub URL inside Docker network is http://selenium-hub:4444/wd/hub. The second argument to RemoteWebDriver is the ChromeOptions object named options.