Bird
0
0

You want to run Selenium tests in headless mode on a Linux server without a display. Which combination of steps is correct to ensure tests run smoothly?

hard📝 Application Q15 of 15
Selenium Python - Cross-Browser Testing
You want to run Selenium tests in headless mode on a Linux server without a display. Which combination of steps is correct to ensure tests run smoothly?
AUse ChromeOptions with '--headless' argument and set '--no-sandbox' and '--disable-dev-shm-usage' arguments
BUse FirefoxOptions with '--headless' and run tests without any additional arguments
CRun Chrome without headless mode but use Xvfb to simulate display
DUse ChromeOptions with '--headless' only; no other arguments needed
Step-by-Step Solution
Solution:
  1. Step 1: Understand Linux server constraints

    Linux servers often lack GUI and have limited shared memory, so Chrome needs extra flags to run headless smoothly.
  2. Step 2: Identify required ChromeOptions

    Adding '--no-sandbox' and '--disable-dev-shm-usage' helps avoid permission and memory issues on Linux servers.
  3. Step 3: Evaluate options

    Use ChromeOptions with '--headless' argument and set '--no-sandbox' and '--disable-dev-shm-usage' arguments correctly includes these flags with '--headless'. Use FirefoxOptions with '--headless' and run tests without any additional arguments misses Linux-specific flags. Run Chrome without headless mode but use Xvfb to simulate display uses Xvfb but not headless mode. Use ChromeOptions with '--headless' only; no other arguments needed misses important flags.
  4. Final Answer:

    Use ChromeOptions with '--headless' argument and set '--no-sandbox' and '--disable-dev-shm-usage' arguments -> Option A
  5. Quick Check:

    Linux headless Chrome needs extra flags for stability [OK]
Quick Trick: Add '--no-sandbox' and '--disable-dev-shm-usage' on Linux [OK]
Common Mistakes:
  • Using headless without Linux-specific flags
  • Assuming Firefox needs no extra setup
  • Relying on Xvfb instead of headless mode

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes