如题,我定义了一个 firefox 和一个 chrome 的 fixture,现在想用参数化的形式来做到用 chrome 和 firefox 分别打开一次浏览器去访问百度,请教应该如何去实现呢?

import pytest
import os
from selenium import webdriver


@pytest.fixture(name='chrome')
def chrome_driver():
    driver = webdriver.Chrome()
    driver.maximize_window()
    yield driver
    driver.close()


@pytest.fixture(name='firefox')
def firefox_driver():
    driver = webdriver.Firefox()
    driver.maximize_window()
    yield driver
    driver.close()


def open_url(driver, url):
    driver.get(url)


@pytest.mark.demo1
def test_login(chrome):
    open_url(chrome, "https://www.baidu.com")


if __name__ == '__main__':
    pytest.main(['-m demo1', os.path.abspath(__file__)])


↙↙↙阅读原文可查看相关链接,并与作者交流