Bird
Raised Fist0
Selenium Pythontesting~20 mins

Chrome configuration in Selenium Python - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Chrome Configuration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What is the output of this Selenium Chrome configuration code?
Consider the following Python Selenium code snippet that configures Chrome options and launches a browser. What will be printed after execution?
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()
ANone
BFalse
CTrue
DKeyError
Attempts:
2 left
💡 Hint
Check how the 'headless' argument affects the capabilities dictionary.
❓ locator
intermediate
1:30remaining
Which Chrome option disables the browser's password manager prompt?
You want to configure Chrome to prevent the password manager popup during automated tests. Which option should you add to ChromeOptions?
A--disable-password-manager
B--disable-save-password-bubble
C--disable-password-save
D--disable-password-manager-reauthentication
Attempts:
2 left
💡 Hint
Look for the option that specifically mentions disabling the save password bubble.
❓ assertion
advanced
2:00remaining
Which assertion correctly verifies Chrome is running in incognito mode?
Given a Selenium WebDriver instance 'driver' configured with ChromeOptions to run in incognito mode, which assertion correctly checks 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)
Aassert '--incognito' in driver.capabilities['goog:chromeOptions']['args']
Bassert driver.capabilities['chromeOptions']['incognito'] is True
Cassert driver.execute_script('return window.navigator.incognito') == True
Dassert driver.capabilities['incognito'] == True
Attempts:
2 left
💡 Hint
Check where ChromeOptions arguments are stored in capabilities.
🔧 Debug
advanced
2:30remaining
Why does this Chrome configuration code raise a SessionNotCreatedException?
Analyze the following code snippet. Why does it raise a SessionNotCreatedException when executed?
Selenium Python
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument('--window-size=1920,1080')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--no-sandbox')
options.add_argument('--remote-debugging-port=9222')

# Incorrect chromedriver path
driver = webdriver.Chrome(executable_path='/wrong/path/chromedriver', options=options)
driver.get('https://example.com')
AThe '--no-sandbox' argument requires root privileges and causes failure.
BThe '--remote-debugging-port' argument conflicts with headless mode.
CThe chromedriver executable path is incorrect, causing failure to start the session.
DThe '--disable-gpu' argument is deprecated and causes errors.
Attempts:
2 left
💡 Hint
Check the executable_path parameter and its correctness.
❓ framework
expert
3:00remaining
Which ChromeOptions configuration ensures maximum test stability in CI environments?
Select the ChromeOptions configuration that best improves test stability and performance in Continuous Integration (CI) environments.
A
options.add_argument('--incognito')
options.add_argument('--disable-popup-blocking')
options.add_argument('--disable-plugins')
B
options.add_argument('--start-maximized')
options.add_argument('--disable-extensions')
options.add_argument('--disable-infobars')
C
options.add_argument('--remote-debugging-port=9222')
options.add_argument('--enable-automation')
options.add_argument('--disable-browser-side-navigation')
D
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
Attempts:
2 left
💡 Hint
Consider options that reduce resource usage and sandbox issues in CI.

Practice

(1/5)
1. What is the main purpose of using Options() in Selenium with Chrome?
easy
A. To locate elements on the web page
B. To handle exceptions during test execution
C. To write assertions for test validation
D. To customize Chrome browser settings before starting tests

Solution

  1. Step 1: Understand the role of Options()

    The Options() class in Selenium is used to set Chrome browser configurations like headless mode, window size, or disabling notifications before launching the browser.
  2. Step 2: Differentiate from other Selenium features

    Locating elements, writing assertions, and handling exceptions are separate tasks unrelated to browser configuration.
  3. Final Answer:

    To customize Chrome browser settings before starting tests -> Option D
  4. Quick Check:

    Options() = Customize browser [OK]
Hint: Options() sets browser behavior before tests run [OK]
Common Mistakes:
  • Confusing Options() with element locators
  • Thinking Options() handles test assertions
  • Assuming Options() manages exceptions
2. Which of the following is the correct way to add headless mode to Chrome using Selenium in Python?
easy
A. options.add_argument('--headless')
B. options.set_headless(True)
C. options.add_argument('headless')
D. options.headless = True

Solution

  1. Step 1: Recall correct syntax for headless argument

    In Selenium, Chrome headless mode is enabled by adding the argument '--headless' with two dashes.
  2. Step 2: Check each option's correctness

    options.add_argument('headless') misses dashes, options.set_headless(True) and D are invalid methods or attributes for Chrome Options.
  3. Final Answer:

    options.add_argument('--headless') -> Option A
  4. Quick Check:

    Headless argument needs '--' prefix [OK]
Hint: Use '--headless' with add_argument() for headless mode [OK]
Common Mistakes:
  • Omitting dashes in argument string
  • Using non-existent methods like set_headless()
  • Assigning headless attribute directly
3. What will be the effect of the following code snippet?
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--incognito')
driver = webdriver.Chrome(options=options)
driver.get('https://example.com')
medium
A. Chrome opens in incognito mode and loads example.com
B. Chrome opens in normal mode and loads example.com
C. Chrome opens but fails to load example.com
D. Code raises a syntax error

Solution

  1. Step 1: Analyze the use of add_argument('--incognito')

    The code adds the '--incognito' argument to Chrome options, which launches the browser in incognito mode.
  2. Step 2: Confirm driver behavior

    The driver is created with these options and navigates to 'https://example.com' successfully without errors.
  3. Final Answer:

    Chrome opens in incognito mode and loads example.com -> Option A
  4. Quick Check:

    --incognito argument = incognito mode [OK]
Hint: Adding '--incognito' opens Chrome in private mode [OK]
Common Mistakes:
  • Assuming incognito disables page loading
  • Thinking code causes syntax errors
  • Confusing incognito with headless mode
4. Identify the error in this Selenium Chrome configuration code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('disable-notifications')
driver = webdriver.Chrome(options=options)
medium
A. No error, code runs fine
B. Missing double dashes in argument string
C. webdriver.Chrome() does not accept options parameter
D. Options() class is not imported correctly

Solution

  1. Step 1: Check argument syntax for disabling notifications

    The argument to disable notifications must start with two dashes: '--disable-notifications'. The code misses these dashes.
  2. Step 2: Verify other parts of the code

    Options() is imported correctly and webdriver.Chrome accepts options parameter, so no errors there.
  3. Final Answer:

    Missing double dashes in argument string -> Option B
  4. Quick Check:

    Arguments need '--' prefix [OK]
Hint: Always prefix Chrome arguments with '--' [OK]
Common Mistakes:
  • Forgetting dashes in argument strings
  • Assuming options parameter is invalid
  • Misimporting Options class
5. You want to run Chrome in headless mode and disable pop-up notifications during tests. Which code snippet correctly sets both options?
hard
A. options = Options() options.headless = True options.add_argument('disable-notifications')
B. options = Options() options.add_argument('--headless') options.add_argument('disable-notifications')
C. options = Options() options.add_argument('--headless') options.add_argument('--disable-notifications')
D. options = Options() options.set_headless(True) options.add_argument('--disable-notifications')

Solution

  1. Step 1: Confirm correct syntax for headless and disabling notifications

    Both arguments must have double dashes: '--headless' and '--disable-notifications'. options = Options() options.add_argument('--headless') options.add_argument('--disable-notifications') uses both correctly.
  2. Step 2: Check invalid methods or missing dashes in other options

    options = Options() options.add_argument('--headless') options.add_argument('disable-notifications') misses dashes for disable-notifications, options = Options() options.headless = True options.add_argument('disable-notifications') assigns headless attribute incorrectly, options = Options() options.set_headless(True) options.add_argument('--disable-notifications') uses non-existent set_headless() method.
  3. Final Answer:

    options.add_argument('--headless') and options.add_argument('--disable-notifications') -> Option C
  4. Quick Check:

    Use '--' prefix for all Chrome options [OK]
Hint: Use '--' before all Chrome option arguments [OK]
Common Mistakes:
  • Missing dashes in argument strings
  • Using invalid methods like set_headless()
  • Assigning headless as attribute instead of argument
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard