0
0
Selenium Javatesting~10 mins

Docker Selenium Grid in Selenium Java - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a Selenium Grid hub container using Docker.

Selenium Java
docker run -d -p 4444:4444 --name selenium-hub [1]
Drag options to blanks, or click blank then click option'
Aselenium/standalone-chrome:4.8.0
Bselenium/hub:4.8.0
Cselenium/node-firefox:4.8.0
Dselenium/node-chrome:4.8.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using a node image instead of the hub image.
Not exposing port 4444.
2fill in blank
medium

Complete the code to start a Chrome node container and connect it to the Selenium Grid hub network.

Selenium Java
docker run -d --network [1] --name chrome-node -e SE_EVENT_BUS_HOST=selenium-hub selenium/node-chrome:4.8.0
Drag options to blanks, or click blank then click option'
Abridge
Bhost
Cselenium-grid
Ddefault
Attempts:
3 left
💡 Hint
Common Mistakes
Using the default or host network which isolates containers.
Not specifying the network, causing communication failure.
3fill in blank
hard

Fix the error in the Docker command to start a Firefox node connected to the Selenium Grid hub.

Selenium Java
docker run -d --network selenium-grid --name firefox-node -e SE_EVENT_BUS_HOST=[1] selenium/node-firefox:4.8.0
Drag options to blanks, or click blank then click option'
Aselenium-hub
B127.0.0.1
Cfirefox-node
Dlocalhost
Attempts:
3 left
💡 Hint
Common Mistakes
Using localhost or 127.0.0.1 which refers to the node container itself.
Using the node's own name instead of the hub's name.
4fill in blank
hard

Fill both blanks to create a Docker network and start the Selenium Grid hub attached to it.

Selenium Java
docker network [1] selenium-grid

docker run -d -p 4444:4444 --network [2] --name selenium-hub selenium/hub:4.8.0
Drag options to blanks, or click blank then click option'
Acreate
Bremove
Cselenium-grid
Dbridge
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'remove' instead of 'create' for the network command.
Not matching the network name in both commands.
5fill in blank
hard

Fill all three blanks to write a Java Selenium test that connects to the Selenium Grid hub and opens a Chrome browser.

Selenium Java
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();
    }
}
Drag options to blanks, or click blank then click option'
Ahttp://localhost:4444/wd/hub
Boptions
Cnew ChromeOptions()
Dhttp://selenium-hub:4444/wd/hub
Attempts:
3 left
💡 Hint
Common Mistakes
Using localhost in the URL which won't work inside Docker network.
Passing a new ChromeOptions() instead of the existing options variable.