1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Why doesn't the web driver close after the first test when the test is run with the...

Discussão em 'Python' iniciado por Stack, Setembro 28, 2024 às 11:22.

  1. Stack

    Stack Membro Participativo

    This problem is about the first test with different parameter. It works, but it doesn't shut down properly. Because of this, the second test with different parameter cannot start.

    Here is the conftest.py:

    @pytest.fixture(scope="class")
    def driver(request):
    driver = BrowserFactory.create_chrome_driver()
    driver.implicitly_wait(10)
    driver.maximize_window()
    driver.get("https://www.saucedemo.com")

    def teardown():
    driver.quit()

    request.addfinalizer(teardown)

    return driver

    @pytest.fixture(scope="class")
    def inventory_object(driver):
    # Create an instance of the Dummy class
    return Inventory(driver)


    @pytest.fixture(scope="class")
    def login_test_data():
    df = pandas.read_csv(r"C:/Users/user/PycharmProjects/pythonProject4/Testdata/login.csv")
    dicts = df.to_dict('records')
    return dicts

    @pytest.fixture(scope="class")
    def login_object(driver):
    return LoginPage(driver)


    Here is the test_inventory.py

    @pytest.mark.parametrize("values", ["za","hilo","liho"])
    def test_select_za(self,values,login_test_data,login_object,inventory_object):
    self.test_login.test_login_successful(login_test_data, login_object)
    print(values)
    inventory_object.select_filter(values)

    Continue reading...

Compartilhe esta Página