0
0
Selenium Pythontesting~10 mins

Browser options and capabilities in Selenium Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a ChromeOptions object.

Selenium Python
from selenium.webdriver.chrome.options import ChromeOptions
options = [1]()
Drag options to blanks, or click blank then click option'
AOptions
BChromeOptions
CChromeDriver
DWebDriver
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Options' instead of 'ChromeOptions' causes an error because the import is specific.
Using 'WebDriver' or 'ChromeDriver' instead of options class.
2fill in blank
medium

Complete the code to add the argument to start Chrome maximized.

Selenium Python
options = ChromeOptions()
options.add_argument([1])
Drag options to blanks, or click blank then click option'
A'--start-maximized'
B'--incognito'
C'--headless'
D'--disable-extensions'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--headless' starts Chrome without UI, not maximized.
Using '--incognito' opens private mode, not maximized.
3fill in blank
hard

Fix the error in the code to set the experimental option to disable automation info bar.

Selenium Python
options = ChromeOptions()
options.add_experimental_option('excludeSwitches', [1])
Drag options to blanks, or click blank then click option'
A['enable-automation']
B'enable-automation'
C['disable-automation']
D'disable-automation'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a string instead of a list causes a type error.
Using 'disable-automation' is incorrect switch name.
4fill in blank
hard

Fill both blanks to create a Firefox profile and set it in FirefoxOptions.

Selenium Python
from selenium.webdriver.firefox.options import FirefoxOptions
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
profile = FirefoxProfile()
options = FirefoxOptions()
options.[1] = profile
browser = webdriver.Firefox(options=options, [2]=profile)
Drag options to blanks, or click blank then click option'
Aprofile
Bfirefox_profile
Cset_profile
Dprofile_path
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set_profile' instead of 'profile' attribute.
Passing 'profile_path' instead of 'firefox_profile' to driver.
5fill in blank
hard

Fill all three blanks to create ChromeOptions, add headless argument, and set window size.

Selenium Python
options = ChromeOptions()
options.add_argument([1])
options.add_argument([2])
driver = webdriver.Chrome(options=options)
# Verify window size is set to 1920x1080
size = driver.get_window_size()
assert size['width'] == [3] and size['height'] == 1080
Drag options to blanks, or click blank then click option'
A'--headless=new'
B'--window-size=1920,1080'
C1920
D'--headless'
Attempts:
3 left
💡 Hint
Common Mistakes
Using old '--headless' may cause different behavior.
Passing window size as separate arguments instead of one string.
Comparing width to string instead of integer.