vendredi 28 août 2020

Python/Pytest fixture value depending on test number

I have created a @pytest.fixture(scope="class") inside which I have added steps in the selenium:

@pytest.fixture(scope="class")
def test_setup1(test_setup):
    driver.click_element()
    driver.enter_price()
    driver.enter_year('1997') <--- test-dependent element
    many steps
    ...
 

Is it possible that one of the elements e.g. driver.enter_year() depends on the element inside test? For example:

def test_order_1 (self, test_setup1):

    date = 1998
    assert element_in_alert('Succes')


def test_order_2 (self, test_setup1):

    date = 1994
    assert element_in_alert('Succes')


Aucun commentaire:

Enregistrer un commentaire