Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a Chrome WebDriver instance.
Selenium Python
from selenium import webdriver options = webdriver.ChromeOptions() driver = webdriver.Chrome(options=[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the class name instead of the options instance.
Passing the driver variable to itself.
Not passing any options at all.
✗ Incorrect
You must pass the ChromeOptions object named 'options' to the Chrome WebDriver constructor to configure the browser.
2fill in blank
mediumComplete the code to add the headless argument to Chrome options.
Selenium Python
from selenium import webdriver options = webdriver.ChromeOptions() options.add_argument('[1]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--disable-gpu' which disables GPU but does not make it headless.
Using '--start-maximized' which opens a window maximized.
Using '--incognito' which opens private browsing mode.
✗ Incorrect
The '--headless' argument runs Chrome without opening a visible window, useful for automated tests.
3fill in blank
hardFix the error in setting the window size in Chrome options.
Selenium Python
from selenium import webdriver options = webdriver.ChromeOptions() options.add_argument('[1]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an 'x' instead of ',' to separate width and height.
Adding spaces between the argument and value.
Using an equal sign with spaces.
✗ Incorrect
The correct format for window size argument uses 'width,height' with a ',' between numbers, no spaces.
4fill in blank
hardFill both blanks to create a Chrome driver with headless mode and disable GPU.
Selenium Python
from selenium import webdriver options = webdriver.ChromeOptions() options.add_argument('[1]') options.add_argument('[2]') driver = webdriver.Chrome(options=options)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--incognito' or '--start-maximized' which do not relate to headless mode.
Forgetting to disable GPU when running headless on some systems.
✗ Incorrect
Headless mode requires '--headless' and often '--disable-gpu' to avoid GPU issues in some environments.
5fill in blank
hardFill all three blanks to create a Chrome driver with a custom user agent, headless mode, and window size 1280x720.
Selenium Python
from selenium import webdriver options = webdriver.ChromeOptions() options.add_argument('[1]') options.add_argument('[2]') options.add_argument('[3]') driver = webdriver.Chrome(options=options)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--disable-extensions' instead of user agent or window size.
Incorrect format for window size argument.
Missing the headless argument.
✗ Incorrect
To customize Chrome, add the user agent string, enable headless mode, and set the window size with correct arguments.