pytest-dev / pytest-html

Plugin for generating HTML reports for pytest results
Other
707 stars 236 forks source link

In Selenium pyTest framework getting error as "fixture 'setup_and_teardown' not found" #817

Closed Tushar7337 closed 4 months ago

Tushar7337 commented 4 months ago

Working on one selenium script using pyTest framework but while passing setup and teardown method from conftest.py file getting error

PFA script for reference

@pytest.mark.usefixtures("setup_and_teardown") class TestSearch: def test_search_for_a_valid_product(self): self.driver.find_element(By.NAME, "search").send_keys("HP") self.driver.find_element(By.XPATH, "//button[contains(@class,'btn-default')]").click() assert self.driver.find_element(By.LINK_TEXT, "HP LP3065").is_displayed()

@pytest.fixture() def setup_and_teardown(request): driver = webdriver.Chrome() driver.maximize_window() driver.get("https://tutorialsninja.com/demo/") request.cls.driver = driver yield driver.quit()

image image

All error are getting to self.driver as to minimize the code delicacy I have written setup and teardown function in conftest.py file `

RonnyPfannschmidt commented 4 months ago

this is the wrong issue tracker for this question

based on the screenshot you named the local plugin wrong (coftest.pyinstead of conftest.py)

Tushar7337 commented 4 months ago

@RonnyPfannschmidt Thanks a lot it works after refactoring file name.