Challenge - 5 Problems
Browser Options 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 browser options code?
Consider the following Python Selenium code snippet that sets Chrome options. What will be printed when the code runs?
Selenium Python
from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument('--headless') options.add_argument('--disable-gpu') driver = webdriver.Chrome(options=options) print(driver.capabilities.get('headless')) driver.quit()
Attempts:
2 left
💡 Hint
Check how the headless argument affects the capabilities dictionary.
✗ Incorrect
When Chrome is launched with the '--headless' option, the capabilities dictionary includes 'headless': True. So printing driver.capabilities.get('headless') outputs True.
❓ assertion
intermediate2:00remaining
Which assertion correctly verifies the browser is running in incognito mode?
You want to check if Chrome is running in incognito mode using Selenium Python. Which assertion correctly verifies this?
Selenium Python
from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument('--incognito') driver = webdriver.Chrome(options=options) # Which assertion below is correct?
Attempts:
2 left
💡 Hint
Check where Chrome options arguments are stored in capabilities.
✗ Incorrect
The incognito mode is passed as an argument in 'goog:chromeOptions' under 'args'. So checking if '--incognito' is in that list is the correct way.
🔧 Debug
advanced2:00remaining
Why does this Selenium code fail to set the user agent?
The following code tries to set a custom user agent in Chrome but it does not work. What is the reason?
Selenium Python
from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument('user-agent=MyCustomAgent/1.0') driver = webdriver.Chrome(options=options) print(driver.execute_script('return navigator.userAgent;')) driver.quit()
Attempts:
2 left
💡 Hint
Check the syntax of Chrome command line arguments.
✗ Incorrect
Chrome command line arguments require two dashes '--' before the argument name. Missing them causes the argument to be ignored.
🧠 Conceptual
advanced1:30remaining
What is the main purpose of browser capabilities in Selenium?
Choose the best description of the main purpose of browser capabilities in Selenium WebDriver.
Attempts:
2 left
💡 Hint
Think about what capabilities configure before the browser starts.
✗ Incorrect
Capabilities tell Selenium how to start the browser with specific settings like headless mode, proxy, or extensions.
❓ framework
expert3:00remaining
How to correctly combine Chrome options and capabilities in Selenium Python?
You want to run Chrome in headless mode and set a proxy using Selenium Python. Which code snippet correctly combines Chrome options and capabilities?
Attempts:
2 left
💡 Hint
Check how to set proxy with Chrome options in Selenium Python 4+.
✗ Incorrect
In Selenium Python 4+, the recommended way is to set proxy via options.set_capability, combining options and capabilities cleanly.