0
0
Selenium Pythontesting~10 mins

Fixtures for browser setup/teardown 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 import the pytest fixture decorator.

Selenium Python
from pytest import [1]
Drag options to blanks, or click blank then click option'
Atest
Bmark
Cfixture
Dparametrize
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'test' or 'mark' instead of 'fixture'.
Forgetting to import the fixture decorator.
2fill in blank
medium

Complete the fixture function to initialize the Chrome browser.

Selenium Python
import pytest
from selenium import webdriver

@pytest.fixture
def browser():
    driver = webdriver.[1]()
    yield driver
    driver.quit()
Drag options to blanks, or click blank then click option'
AChrome
BSafari
CFirefox
DEdge
Attempts:
3 left
💡 Hint
Common Mistakes
Using Firefox or Safari when Chrome is required.
Forgetting to call the browser constructor as a function.
3fill in blank
hard

Fix the error in the fixture to properly close the browser after the test.

Selenium Python
@pytest.fixture
def browser():
    driver = webdriver.Chrome()
    yield driver
    driver.[1]()
Drag options to blanks, or click blank then click option'
Aexit
Bquit
Cstop
Dclose
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'close' which only closes one tab.
Using non-existent methods like 'stop' or 'exit'.
4fill in blank
hard

Fill both blanks to create a fixture that opens Firefox and maximizes the window before yielding.

Selenium Python
@pytest.fixture
def browser():
    driver = webdriver.[1]()
    driver.[2]()
    yield driver
    driver.quit()
Drag options to blanks, or click blank then click option'
AFirefox
BChrome
Cmaximize_window
Dminimize_window
Attempts:
3 left
💡 Hint
Common Mistakes
Using Chrome instead of Firefox.
Using 'minimize_window' instead of 'maximize_window'.
5fill in blank
hard

Fill all three blanks to create a fixture that opens Edge, sets an implicit wait, and then yields the driver.

Selenium Python
@pytest.fixture
def browser():
    driver = webdriver.[1]()
    driver.[2](10)
    yield driver
    driver.[3]()
Drag options to blanks, or click blank then click option'
AEdge
Bimplicitly_wait
Cquit
Dmaximize_window
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'maximize_window' instead of 'implicitly_wait'.
Forgetting to call 'quit()' to close the browser.