Skip to content
CodeKruPro

Read the Compose file: is Selenium ready when tests start?

QuizMedium-HardAsked in: Capgemini, Swiggy

Read the Compose file.

docker-compose.yml

services:
  chrome:
    image: selenium/standalone-chrome:4.45.0
    shm_size: 2gb
    ports:
      - "4444:4444"
  tests:
    build: .
    depends_on:
      - chrome
    environment:
      SELENIUM_URL: http://chrome:4444

Does depends_on guarantee that Selenium is ready to accept sessions before the tests start?

  • No. It only starts chrome before tests; the tests should wait until the Grid status endpoint reports ready, or chrome needs a healthcheck (a command Docker runs to test whether the service works) and condition: service_healthy
  • Yes, Compose waits until Selenium accepts sessions
  • Yes, because the port is mapped
  • No, and tests always start first

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in