0
0
Selenium Pythontesting~5 mins

pytest with Selenium setup in Selenium Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Anpm install pytest selenium
Bpip install pytest selenium
Capt-get install pytest selenium
Dpip install selenium pytest-runner
What does a pytest fixture typically do in Selenium tests?
ARuns tests in parallel
BGenerates test reports
CSets up and tears down browser sessions
DFinds elements on the page
In pytest, what keyword is used inside a fixture to pause setup and resume cleanup?
Ayield
Breturn
Cbreak
Dcontinue
Which Selenium WebDriver is used to open Chrome browser in Python?
Awebdriver.Chrome()
Bwebdriver.Edge()
Cwebdriver.Safari()
Dwebdriver.Firefox()
What is the main benefit of using pytest with Selenium?
AIt writes code for you
BIt automatically fixes bugs
CIt replaces the need for browsers
DIt helps organize and run automated browser tests easily
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.