1
votes

I'm calling the following code using pytest.

@pytest.fixture(scope='class')
    def driver_init(request):
        ch_driver = webdriver.Chrome(executable_path=Data.Ch_exe_path)
        request.cls.driver = ch_driver
        yield
        ch_driver.close()
    
    
    @pytest.mark.usefixtures("driver_init")

I'm getting an error saying

fixture 'driver_init' not found. available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, extra, metadata, monkeypatch, pytestcon fig, record_property, record_testsuite_property, record_xml_attribute, recwarn, testrun_uid, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory , worker_id.

1
Looks ok to me - can you show the test class after the decorator? Is there more code that uses the fixture? - MrBean Bremen

1 Answers

0
votes

It is Working when I change the function name to "setup" instead of "driver_init".