P
P
PesyCorm2021-07-31 19:16:07
Python
PesyCorm, 2021-07-31 19:16:07

How to properly run parametrized pytest + selenium?

Hey! Tell me please, how can I run a parameterized pytest test using the selenium driver?

What do I have:

  1. conftest.py file

    @pytest.fixture(scope="function")
    def driver(request):
    
        driver = webdriver.Chrome()
        request.addfinalizer(driver.quit)
        return driver

  2. the test itself
    data = [{1: 2}, {2: 3}]
    
    @pytest.mark.parametrize('number1', 'number2', data)
    def test_01(driver, number1, number2):
        pass



i.e., the driver from conftest.py is transferred to the test + I need to get data through pytest.mark.parametrize
with the code that I get an error
610576fbaabda231330002.png
Tell me how to do it right? Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
taktik, 2021-07-31
@PesyCorm

@pytest.mark.parametrize('number1, number2', [
    ({1: 2}, {2: 3})
])
def test_01(driver, number1, number2):
    pass

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question