0
0
Selenium Pythontesting~20 mins

Docker-based Grid in Selenium Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Docker Grid Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of Selenium Grid Node Registration Log
You start a Selenium Grid node using Docker with the command:
docker run -d --net=host -e SE_EVENT_BUS_HOST=localhost -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 selenium/node-chrome:latest

What will be the expected output in the node's Docker logs indicating successful registration?
AERROR - Could not connect to the hub at http://localhost:4444
BINFO - Registered a node with the hub: http://localhost:4444
CWARN - Node is running but not registered to any hub
DFATAL - Missing environment variables for event bus
Attempts:
2 left
💡 Hint
Look for logs that confirm successful connection to the hub.
assertion
intermediate
2:00remaining
Correct Assertion for Node Availability in Selenium Grid
You want to write a test to assert that a Selenium Grid node is available and ready to accept sessions. Which assertion correctly checks the node's readiness using Selenium Python bindings?
Selenium Python
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

driver = webdriver.Remote(
    command_executor='http://localhost:4444/wd/hub',
    desired_capabilities=DesiredCapabilities.CHROME)

# Which assertion below correctly verifies the node is ready?
Aassert driver.session_id is not None
Bassert driver is None
Cassert driver.title == ''
Dassert driver.current_url == 'about:blank'
Attempts:
2 left
💡 Hint
A valid session_id means the node accepted the session.
🔧 Debug
advanced
2:00remaining
Debugging Selenium Grid Node Connection Failure
You run a Selenium Grid hub and a node in Docker containers on the same machine. The node fails to register with the hub. The node's Docker logs show:
ERROR - Could not connect to the hub at http://localhost:4444

What is the most likely cause?
AThe node image is outdated and incompatible with the hub.
BThe hub is not running on port 4444.
CDocker network is misconfigured to block all traffic.
DThe node container cannot reach the hub at localhost because localhost refers to itself inside the container.
Attempts:
2 left
💡 Hint
Remember how localhost behaves inside Docker containers.
framework
advanced
2:00remaining
Best Practice for Scaling Selenium Grid with Docker
You want to scale your Selenium Grid to run multiple Chrome and Firefox nodes using Docker Compose. Which approach correctly defines the services for scaling nodes?
Selenium Python
version: '3'
services:
  selenium-hub:
    image: selenium/hub:latest
    ports:
      - '4444:4444'
  chrome:
    image: selenium/node-chrome:latest
    depends_on:
      - selenium-hub
    environment:
      - SE_EVENT_BUS_HOST=selenium-hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
  firefox:
    image: selenium/node-firefox:latest
    depends_on:
      - selenium-hub
    environment:
      - SE_EVENT_BUS_HOST=selenium-hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
AManually start multiple containers with different ports mapped.
BRun multiple docker-compose files separately for each node.
CAdd 'deploy: replicas: 3' under chrome and firefox services to scale nodes.
DUse 'scale' command in docker-compose CLI to add nodes dynamically.
Attempts:
2 left
💡 Hint
Docker Compose version 3 supports replicas for scaling services.
🧠 Conceptual
expert
2:00remaining
Understanding Event Bus Ports in Selenium Grid Docker Setup
In a Docker-based Selenium Grid setup, the environment variables SE_EVENT_BUS_HOST, SE_EVENT_BUS_PUBLISH_PORT, and SE_EVENT_BUS_SUBSCRIBE_PORT are set for nodes. What is the primary purpose of these event bus ports?
AThey enable communication between the hub and nodes for session management and status updates.
BThey expose the browser debugging ports for remote inspection.
CThey are used to forward HTTP traffic from the hub to the nodes.
DThey configure the ports for Selenium WebDriver commands to reach the browsers.
Attempts:
2 left
💡 Hint
Think about how the hub and nodes coordinate in a distributed grid.