Reputation: 169
I have my own Browser class and created a new CLI argument to be able to execute tests with different browsers.
main conftest.py
def pytest_addoption(parser):
parser.addoption('--browser_type', action="store", default="chromium")
def pytest_configure(config):
os.environ["browser_type"] = config.getoption("browser_type")
folder conftest.py
@pytest.fixture(scope="class")
def page_custom():
params = Browser.context_parameters
if not Browser.running_chromium:
Browser("chrome", **Browser.browser_parameters)
context = Browser.open_new_context(**params)
Browser.context = context
page = context.new_page()
Browser.page = page
yield page
page.close()
Do you have any idea how could I add the parametrize to page_custom method? Like
@pytest.mark.parametrize("browser_type", os.environ["browser_type"])
...
But not sure how should I change the page_custom to get this parameter in consideration and if I'm calling the test with --browser_type firefox then the test is using firefox
Upvotes: 0
Views: 17