Answer the question
In order to leave comments, you need to log in
How to import fixture into a test?
Good time of the day. There is a test (using selenium) - checking the addition of goods to the cart. Created a separate selenium_fixture file that would open and close the browser:
from selenium import webdriver
import pytest
@pytest.fixture
def driver(request):
driver = webdriver.Firefox()
driver.implicitly_wait(10)
request.addfinalizer(driver.quit)
return (driver)
In the test itself I write from selenium_fixture import driver, but for some reason it is not imported. I'm doing it in the pycharm development environment. Added the pytest library to the environment. Also, in the settings in the Python integrated tools section, I set py.test in the Default test runner field. All the same, the test does not run, the module is not imported.
Tell me what it can be, what I'm doing wrong?
Answer the question
In order to leave comments, you need to log in
Move the fixture to the conftest.py file. The fixtures in this file are applied automatically.
@pytest.fixture(scope="session")
def driver(request):
driver = webdriver.Firefox()
driver.implicitly_wait(10)
request.addfinalizer(driver.quit)
return(driver)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question