0
0
Selenium Pythontesting~10 mins

Conftest for shared fixtures 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 pytest for fixture usage.

Selenium Python
import [1]

@pytest.fixture
def browser():
    pass
Drag options to blanks, or click blank then click option'
Apytest
Bunittest
Cselenium
Drequests
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unittest instead of pytest.
Importing selenium instead of pytest.
2fill in blank
medium

Complete the fixture to initialize a Chrome WebDriver.

Selenium Python
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
BEdge
CSafari
DFirefox
Attempts:
3 left
💡 Hint
Common Mistakes
Using webdriver.Firefox() when Chrome is required.
Forgetting to quit the driver after tests.
3fill in blank
hard

Fix the error in the fixture to properly yield the driver.

Selenium Python
@pytest.fixture
def browser():
    driver = webdriver.Chrome()
    [1] driver
    driver.quit()
Drag options to blanks, or click blank then click option'
Areturn
Bpass
Cprint
Dyield
Attempts:
3 left
💡 Hint
Common Mistakes
Using return instead of yield causes driver.quit() to never run.
Using pass or print does not provide the driver to tests.
4fill in blank
hard

Fill both blanks to create a fixture that sets an implicit wait and maximizes the window.

Selenium Python
@pytest.fixture
def browser():
    driver = webdriver.Chrome()
    driver.[1](10)
    driver.[2]()
    yield driver
    driver.quit()
Drag options to blanks, or click blank then click option'
Aimplicitly_wait
Bmaximize_window
Cget
Dclose
Attempts:
3 left
💡 Hint
Common Mistakes
Using get() instead of maximize_window() to resize window.
Using close() instead of quit() to end session.
5fill in blank
hard

Fill all three blanks to create a fixture that opens a URL, waits implicitly, and maximizes the window.

Selenium Python
@pytest.fixture
def browser():
    driver = webdriver.Chrome()
    driver.[1]('https://example.com')
    driver.[2](5)
    driver.[3]()
    yield driver
    driver.quit()
Drag options to blanks, or click blank then click option'
Aget
Bimplicitly_wait
Cmaximize_window
Drefresh
Attempts:
3 left
💡 Hint
Common Mistakes
Using refresh() instead of get() to open URL.
Forgetting to yield the driver before quitting.