Recall & Review
beginner
What is pytest and why is it used with Selenium?
pytest is a testing framework for Python that helps write and run tests easily. It is used with Selenium to automate browser actions and verify web application behavior.
Click to reveal answer
beginner
How do you install pytest and Selenium in Python?
Use the command
pip install pytest selenium in your terminal or command prompt to install both pytest and Selenium libraries.Click to reveal answer
intermediate
What is a pytest fixture and how is it useful in Selenium tests?
A pytest fixture is a function that runs before a test to set up needed resources, like opening a browser. It helps reuse setup code and clean up after tests.
Click to reveal answer
intermediate
Show a simple pytest fixture example that opens and closes a Chrome browser using Selenium.
import pytest
from selenium import webdriver
@pytest.fixture
def browser():
driver = webdriver.Chrome()
yield driver
driver.quit()Click to reveal answer
intermediate
Why should you use
yield in a pytest fixture for Selenium?Using
yield allows the fixture to provide the browser to the test, then run cleanup code (like closing the browser) after the test finishes.Click to reveal answer
Which command installs pytest and Selenium for Python?
✗ Incorrect
The correct command is
pip install pytest selenium to install both pytest and Selenium Python packages.What does a pytest fixture typically do in Selenium tests?
✗ Incorrect
Fixtures set up resources like browser sessions before tests and clean them up after tests.
In pytest, what keyword is used inside a fixture to pause setup and resume cleanup?
✗ Incorrect
The
yield keyword pauses the fixture to run the test, then resumes to run cleanup code.Which Selenium WebDriver is used to open Chrome browser in Python?
✗ Incorrect
Use
webdriver.Chrome() to open the Chrome browser.What is the main benefit of using pytest with Selenium?
✗ Incorrect
pytest helps organize and run Selenium browser tests in a simple and readable way.
Explain how to set up a pytest fixture for Selenium WebDriver and why it is useful.
Think about setup and cleanup steps in tests.
You got /5 concepts.
Describe the steps to install and run a simple Selenium test using pytest.
Start from installation to running tests.
You got /5 concepts.