0
0
Selenium Pythontesting~20 mins

Running Selenium in CI pipeline in Selenium Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Selenium CI Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of Selenium WebDriver in headless mode
What will be the output when running this Selenium Python script in a CI pipeline with headless Chrome?
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
driver.quit()
print(title)
AExample Domain
Bselenium.common.exceptions.WebDriverException
CNo output (script hangs)
DChromeDriver not found error
Attempts:
2 left
💡 Hint
Headless mode allows Chrome to run without opening a window, so the page title can still be retrieved.
Troubleshoot
intermediate
2:00remaining
Fixing ChromeDriver version mismatch error in CI
In a CI pipeline, Selenium tests fail with the error: 'This version of ChromeDriver only supports Chrome version 90'. What is the best way to fix this?
ARemove the --headless argument from Chrome options
BDowngrade Selenium to an older version
CUpdate ChromeDriver to match the installed Chrome browser version
DIncrease the timeout for WebDriver initialization
Attempts:
2 left
💡 Hint
ChromeDriver and Chrome browser versions must be compatible.
Configuration
advanced
2:00remaining
Configuring Selenium to run with Firefox in CI
Which configuration snippet correctly sets up Selenium WebDriver to run Firefox in headless mode in a CI pipeline?
A
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)
B
from selenium import webdriver
options = webdriver.FirefoxOptions()
options.add_argument('--headless')
driver = webdriver.Firefox(options=options)
C
from selenium import webdriver
options = webdriver.FirefoxOptions()
options.headless = True
driver = webdriver.Firefox(options=options)
D
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.add_argument('--headless')
driver = webdriver.Firefox(options=options)
Attempts:
2 left
💡 Hint
Use the correct import and method to add headless argument for Firefox.
🔀 Workflow
advanced
2:00remaining
Best CI workflow step to run Selenium tests
In a CI pipeline, which step order ensures Selenium tests run reliably with Chrome in headless mode?
ARun Selenium tests -> Install Chrome -> Install ChromeDriver -> Cleanup
BInstall Chrome -> Install ChromeDriver -> Run Selenium tests -> Cleanup
CInstall ChromeDriver -> Install Chrome -> Run Selenium tests -> Cleanup
DInstall Chrome -> Run Selenium tests -> Install ChromeDriver -> Cleanup
Attempts:
2 left
💡 Hint
Chrome and ChromeDriver must be installed before running tests.
🧠 Conceptual
expert
2:00remaining
Why use virtual display (Xvfb) in Selenium CI pipelines?
What is the main reason to use a virtual display like Xvfb when running Selenium tests in CI pipelines on Linux servers?
ATo provide a graphical environment for browsers to run without a physical display
BTo speed up browser startup time by caching display data
CTo enable running tests in parallel on multiple CPU cores
DTo automatically update browser drivers to the latest version
Attempts:
2 left
💡 Hint
Linux servers often lack a graphical desktop environment.