Challenge - 5 Problems
Headless CI Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Selenium headless mode setup code?
Consider this Python Selenium code snippet that sets up a Chrome browser in headless mode for CI testing. What will be printed after running this code?
Selenium Python
from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument('--headless') options.add_argument('--disable-gpu') try: driver = webdriver.Chrome(options=options) driver.get('https://example.com') title = driver.title print(title) driver.quit() except Exception as e: print(f'Error: {e}')
Attempts:
2 left
💡 Hint
Headless mode runs Chrome without opening a window but still loads the page and its title.
✗ Incorrect
The code sets Chrome to headless mode and navigates to example.com. The page title is 'Example Domain'. If ChromeDriver is correctly installed and in PATH, the title prints successfully.
❓ assertion
intermediate1:30remaining
Which assertion correctly verifies the page title in headless mode?
You want to assert that the page title is exactly 'Example Domain' after loading the page in headless mode. Which assertion statement is correct?
Selenium Python
from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument('--headless') driver = webdriver.Chrome(options=options) driver.get('https://example.com') title = driver.title # Which assertion below is correct?
Attempts:
2 left
💡 Hint
The page title is case sensitive and exactly 'Example Domain'.
✗ Incorrect
The correct assertion checks that the title equals 'Example Domain' exactly. Other options either negate or mismatch the title.
🔧 Debug
advanced2:30remaining
Why does this headless Chrome test fail with a WebDriverException?
This Selenium Python code runs in CI but fails with the error: 'unknown error: Chrome failed to start'. What is the most likely cause?
Selenium Python
from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument('--headless') # Missing this option causes failure in some CI environments # options.add_argument('--no-sandbox') driver = webdriver.Chrome(options=options) driver.get('https://example.com') print(driver.title) driver.quit()
Attempts:
2 left
💡 Hint
Some CI environments restrict sandboxing, requiring a special Chrome option.
✗ Incorrect
In many CI systems, Chrome must run with '--no-sandbox' to avoid startup failure. Without it, Chrome cannot start in headless mode.
❓ locator
advanced2:00remaining
Which locator strategy is best for stable element selection in headless CI tests?
You want to select a button with text 'Submit' in a page tested in headless mode. Which locator is most reliable for CI tests?
Attempts:
2 left
💡 Hint
Text-based XPath is precise if the button text is unique and stable.
✗ Incorrect
XPath with exact button text is less likely to break if classes or IDs change. Other locators may be less specific or unstable.
❓ framework
expert3:00remaining
Which CI pipeline step correctly runs Selenium tests in headless mode with Chrome on Linux?
You configure a CI pipeline to run Selenium Python tests with headless Chrome on a Linux runner. Which step setup is correct?
Attempts:
2 left
💡 Hint
Linux CI runners often require special Chrome options and explicit installation.
✗ Incorrect
For stable headless Chrome tests in Linux CI, install Chrome and ChromeDriver, and use '--headless', '--no-sandbox', and '--disable-dev-shm-usage' to avoid resource and sandbox issues.